main.js 4.87 KB
var express = require('express')
var app = express()
var fs = require('fs');
// var path = require('path');
// var qs = require('querystring');
// var sanitizeHtml = require('sanitize-html');
var template = require('./lib/template.js');

app.use(express.static('data'));
app.get('/', function(request, response) { 
    fs.readdir('./data', function(error, filelist){
      var title = 'Health Care';
      var description = '오늘은 얼마나 먹었어요?';
      var list = template.list(filelist);
      var ch='15ch'
      var html = template.HTML(title,ch,'', list,
        `<h1 style="font-size: 50px; text-align: center; ">${description}</h1>`,
        `<div id = "login-ing" style="width:100%; text-align: center; margin-top: 5ch"> 
        <div class="form-inline">
                <form action="/login" method="post">
                    <label>ID</label>
                    <input type="text" name="name" class="form-control" placeholder="홍길동" style="width:200px;">
                    &nbsp &nbsp&nbsp&nbsp
          
                   <label>Password</label>
                   <input type="password" name="birth" class="form-control" placeholder="*******" style="width:200px;">
                   <br><br><br>
                   <input type="submit" value="Login" class="btn btn-default" style=" width:100px;font-weight: bold; font-size: 18px; background-color: white;">
                   </form>
                   <br><br>
                   <form action="/signup" method="get">
                   <input type="submit" value="Sign Up" class="btn btn-default" style=" width:100px;font-weight: bold; font-size: 18px; background-color: white;">
                   </form>
            </div>
        
</div>`
      ); 
      response.send(html);
    });
  });

  app.get('/signup', function(request, response) { 
    fs.readdir('./data', function(error, filelist){
      var title = 'Sign Up Page';
      var description = '오늘은 얼마나 먹었어요?';
      var list = template.list(filelist);
      var ch='5ch'
      var html = template.HTML(title,ch,`<link rel="stylesheet" type="text/css" href="./a.css" />`, list,
        `<h1 style="width: 100%; text-align: center; font-size: 40px;">${description}</h1>`,
`<div id = "signup-ing" style="width:100%; text-align: center;">
<form action="/starting" method="post">
    <div class="form-inline">
        <div class="input-area">
            <span class="input-label">
                <label name="ID">ID</label>
            </span>
            <span class="input-box">
                <input type="text" name="ID" >
            </span>
        </div>

        <div class="input-area">
                <span class="input-label">
                    <label name="Password">Password</label>
                </span>
                <span class="input-box">
                    <input type="text" name="Password" >
                </span>
            </div>

            <div class="input-area">
                    <span class="input-label">
                        <label name="age">나이(세)</label>
                    </span>
                    <span class="input-box">
                        <input type="text" name="age" >
                    </span>
                </div>

                <div class="input-area">
                        <span class="input-label">
                            <label name="male/female">성별</label>
                        </span>
                        <select id="male/female" style="width: 200px; ">
                            <option>성별 선택</option>
                            <option>남자</option>
                            <option>여자</option>
                        
                        </select>
                    </div>
            
                    <div class="input-area">
                            <span class="input-label">
                                <label name="height">키(cm)</label>
                            </span>
                            <span class="input-box">
                                <input type="text" name="height" > 
                            </span>
                            
                        </div>

                        <div class="input-area">
                                <span class="input-label">
                                    <label name="weight">체중(kg)</label>
                                </span>
                                <span class="input-box">
                                    <input type="text" name="weight" >
                                </span>
                            </div>

       <br><br><br>

        <input type="submit" value="Sign Up" class="btn btn-default" style=" width:100px;font-weight: bold; font-size: 18px; background-color: white;">
    </div>
</form>
</div>`
      ); 
      response.send(html);
    });
  });

  app.listen(3000, function() {
    console.log('Example app listening on port 3000!')
  });