Showing
4 changed files
with
97 additions
and
4 deletions
... | @@ -2,9 +2,19 @@ const express = require('express'); | ... | @@ -2,9 +2,19 @@ const express = require('express'); |
2 | const bodyParser = require('body-parser'); | 2 | const bodyParser = require('body-parser'); |
3 | const session = require('express-session'); | 3 | const session = require('express-session'); |
4 | const app = express(); | 4 | const app = express(); |
5 | +const mySql = require('mysql'); | ||
6 | + | ||
7 | +const pool = mySql.createPool({ | ||
8 | + connectionLimit: 10, | ||
9 | + host: 'localhost', | ||
10 | + user: 'root', | ||
11 | + password: 'root', | ||
12 | + database: 'mapmory', | ||
13 | + debug: false | ||
14 | +}); | ||
5 | 15 | ||
6 | -app.set('views', __dirname + '/views'); | ||
7 | app.set('view engine', 'ejs'); | 16 | app.set('view engine', 'ejs'); |
17 | +app.set('views', __dirname + '/views'); | ||
8 | app.engine('html', require('ejs').renderFile); | 18 | app.engine('html', require('ejs').renderFile); |
9 | app.use(express.static('public')); | 19 | app.use(express.static('public')); |
10 | 20 | ||
... | @@ -18,14 +28,19 @@ app.use(session({ | ... | @@ -18,14 +28,19 @@ app.use(session({ |
18 | saveUninitialized: false, | 28 | saveUninitialized: false, |
19 | })); | 29 | })); |
20 | 30 | ||
21 | -//Home | 31 | +//Home page |
22 | app.get('/', function(req,res){ | 32 | app.get('/', function(req,res){ |
23 | res.render("index.html"); | 33 | res.render("index.html"); |
24 | }) | 34 | }) |
25 | 35 | ||
36 | +//Login page | ||
37 | +app.get('/login', function(req,res){ | ||
38 | + res.render("login.html"); | ||
39 | +}) | ||
40 | + | ||
26 | //login | 41 | //login |
27 | app.put('/login',function(req,res){ | 42 | app.put('/login',function(req,res){ |
28 | - res.send("Login page"); | 43 | + res.send("login.html"); |
29 | }) | 44 | }) |
30 | 45 | ||
31 | //logout | 46 | //logout |
... | @@ -34,7 +49,24 @@ app.put('/logout',function(req,res){ | ... | @@ -34,7 +49,24 @@ app.put('/logout',function(req,res){ |
34 | }) | 49 | }) |
35 | 50 | ||
36 | //register | 51 | //register |
52 | + | ||
53 | +app.get('/register', function(req,res){ | ||
54 | + res.send("register.html"); | ||
55 | +}) | ||
56 | + | ||
37 | app.post('/register',function(req,res){ | 57 | app.post('/register',function(req,res){ |
58 | + console.log('/register 호출됨'); | ||
59 | + | ||
60 | + var user = { | ||
61 | + 'ID': req.body.id, | ||
62 | + 'PWD': req.body.pwd, | ||
63 | + 'NAME': req.body.name | ||
64 | + } | ||
65 | + console.log('ID: ' + user.id + ', PWD: ' + user.PWD + ', NAME: ' + user.NAME); | ||
66 | + | ||
67 | + | ||
68 | + | ||
69 | + //connection.query('INSERT INTO USER SET ?', user, function(error, results, fields)) | ||
38 | res.send('Register page'); | 70 | res.send('Register page'); |
39 | }) | 71 | }) |
40 | 72 | ... | ... |
... | @@ -45,7 +45,7 @@ | ... | @@ -45,7 +45,7 @@ |
45 | text-align: center; | 45 | text-align: center; |
46 | display: inline-block; | 46 | display: inline-block; |
47 | font-size: 1.25rem; | 47 | font-size: 1.25rem; |
48 | - margin:10px; | 48 | + margin:20px; |
49 | cursor:pointer; | 49 | cursor:pointer; |
50 | border-radius:10px; | 50 | border-radius:10px; |
51 | } | 51 | } | ... | ... |
Mapmory/views/login.html
0 → 100644
1 | +<!DOCTYPE html> | ||
2 | +<html> | ||
3 | + <head> | ||
4 | + <meta charset="UTF-8"> | ||
5 | + <title>Mapmory-Login</title> | ||
6 | + </head> | ||
7 | + <body> | ||
8 | + <h1>Login</h1> | ||
9 | + <form method="put" action="/login"> | ||
10 | + <table> | ||
11 | + <tr> | ||
12 | + <td><label>ID : </label></td> | ||
13 | + <td><input type="text" name="id"></td> | ||
14 | + </tr> | ||
15 | + <tr> | ||
16 | + <td><label>PWD : </label></td> | ||
17 | + <td><input type="text" name="pwd"></td> | ||
18 | + </tr> | ||
19 | + | ||
20 | + <tr> | ||
21 | + <td><input type="submit" value="Login" name=""></td> | ||
22 | + <a class="start" href="/register">Join</a> | ||
23 | + </tr> | ||
24 | + </table> | ||
25 | + </form> | ||
26 | + </body> | ||
27 | +</html> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
Mapmory/views/register.html
0 → 100644
1 | +<!DOCTYPE html> | ||
2 | +<html> | ||
3 | +<head> | ||
4 | + <meta charset="UTF-8" /> | ||
5 | + <title>Mapmory-Register</title> | ||
6 | +</head> | ||
7 | +<body> | ||
8 | + <h1>Add User</h1> | ||
9 | + <form method="post" action="/register"> | ||
10 | + <table> | ||
11 | + <tr> | ||
12 | + <td><label>ID : </label></td> | ||
13 | + <td><input type="text" name="id"></td> | ||
14 | + </tr> | ||
15 | + <tr> | ||
16 | + <td><label>PWD : </label></td> | ||
17 | + <td><input type="text" name="pwd"></td> | ||
18 | + </tr> | ||
19 | + | ||
20 | + <tr> | ||
21 | + <td><label>NAME : </label></td> | ||
22 | + <td><input type="text" name="name"></td> | ||
23 | + </tr> | ||
24 | + | ||
25 | + <tr> | ||
26 | + <td><input type="submit" value="Submit" name=""></td> | ||
27 | + </tr> | ||
28 | + | ||
29 | + </table> | ||
30 | + | ||
31 | + </form> | ||
32 | + | ||
33 | +</body> | ||
34 | +</html> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment