임태민

Update app.js

On Construction...
......@@ -2,9 +2,19 @@ const express = require('express');
const bodyParser = require('body-parser');
const session = require('express-session');
const app = express();
const mySql = require('mysql');
const pool = mySql.createPool({
connectionLimit: 10,
host: 'localhost',
user: 'root',
password: 'root',
database: 'mapmory',
debug: false
});
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.set('views', __dirname + '/views');
app.engine('html', require('ejs').renderFile);
app.use(express.static('public'));
......@@ -18,14 +28,19 @@ app.use(session({
saveUninitialized: false,
}));
//Home
//Home page
app.get('/', function(req,res){
res.render("index.html");
})
//Login page
app.get('/login', function(req,res){
res.render("login.html");
})
//login
app.put('/login',function(req,res){
res.send("Login page");
res.send("login.html");
})
//logout
......@@ -34,7 +49,24 @@ app.put('/logout',function(req,res){
})
//register
app.get('/register', function(req,res){
res.send("register.html");
})
app.post('/register',function(req,res){
console.log('/register 호출됨');
var user = {
'ID': req.body.id,
'PWD': req.body.pwd,
'NAME': req.body.name
}
console.log('ID: ' + user.id + ', PWD: ' + user.PWD + ', NAME: ' + user.NAME);
//connection.query('INSERT INTO USER SET ?', user, function(error, results, fields))
res.send('Register page');
})
......
......@@ -45,7 +45,7 @@
text-align: center;
display: inline-block;
font-size: 1.25rem;
margin:10px;
margin:20px;
cursor:pointer;
border-radius:10px;
}
......
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Mapmory-Login</title>
</head>
<body>
<h1>Login</h1>
<form method="put" action="/login">
<table>
<tr>
<td><label>ID : </label></td>
<td><input type="text" name="id"></td>
</tr>
<tr>
<td><label>PWD : </label></td>
<td><input type="text" name="pwd"></td>
</tr>
<tr>
<td><input type="submit" value="Login" name=""></td>
<a class="start" href="/register">Join</a>
</tr>
</table>
</form>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Mapmory-Register</title>
</head>
<body>
<h1>Add User</h1>
<form method="post" action="/register">
<table>
<tr>
<td><label>ID : </label></td>
<td><input type="text" name="id"></td>
</tr>
<tr>
<td><label>PWD : </label></td>
<td><input type="text" name="pwd"></td>
</tr>
<tr>
<td><label>NAME : </label></td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td><input type="submit" value="Submit" name=""></td>
</tr>
</table>
</form>
</body>
</html>
\ No newline at end of file