Toggle navigation
Toggle navigation
This project
Loading...
Sign in
고다경
/
Open_Source_project
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김용재
2019-06-06 11:57:18 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3b3fa6984b8f4f471864b5aefc881ba9bc884886
3b3fa698
1 parent
4e51b5c0
회원가입, 로그인 구현 완료 사용자 정보 db에 저장
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
148 additions
and
22 deletions
contents/Input.html
contents/main → contents/main.html
contents/signup → contents/signup.html
data/main.html
db.json
lib/template.js
main.js
sessions/eaaQvF4tffWqI4OAaU_Fhz-s6covIMoK.json
contents/Input.html
0 → 100644
View file @
3b3fa69
<h1
style=
"width: 100%; text-align: center; font-size: 40px;"
>
오늘은 얼마나 먹었어요?
</h1>
<form
action=
"/logout"
method=
"get"
>
<input
id =
"logout"
type=
"submit"
value=
"Logout"
class=
"btn btn-default"
style=
" width:100px;font-weight: bold; font-size: 18px; background-color: white;"
>
</form>
<br><br><br>
<div
id =
"input-ing"
style=
"width:100%; text-align: center;"
>
<form
action=
"/starting"
method=
"post"
>
<div
class=
"form-inline"
>
<p
style=
"text-decoration-line: underline; font-weight:bold;"
>
오늘 먹은 것들을 적어주세요!
</p>
<input
type=
"text"
style=
"width:30%; height:130px;"
placeholder=
"ex) coffee and croissant"
>
<br><br><br><br>
<input
id=
"go"
type=
"button"
value=
"Go!"
style=
" width:100px; height:80px; font-weight: bold; color:white; font-size: 25px; background-color: rgb(104, 211, 104); border-radius: 2em;"
>
</div>
</form>
</div>
\ No newline at end of file
contents/main
→
contents/main
.html
View file @
3b3fa69
...
...
@@ -5,15 +5,15 @@
<div
id =
"login-ing"
style=
"width:100%; text-align: center; margin-top: 5ch"
>
<div
class=
"form-inline"
>
<form action="/login" method="post">
<form
action=
"/login
_process
"
method=
"post"
>
<label>
ID
</label>
<input type="text" name="
name
" class="form-control" placeholder="홍길동" style="width:200px;">
<input
type=
"text"
name=
"
ID
"
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;">
<input
type=
"password"
name=
"
pwd
"
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;">
<input
type=
"submit"
value=
"
login
"
style=
" width:100px;font-weight: bold; font-size: 18px; background-color: white;"
>
</form>
<br><br>
<form
action=
"/signup"
method=
"get"
>
...
...
contents/signup
→
contents/signup
.html
View file @
3b3fa69
...
...
@@ -4,7 +4,7 @@
<br><br><br>
<div
id =
"signup-ing"
style=
"width:100%; text-align: center;"
>
<form action="/s
tarting
" method="post">
<form
action=
"/s
ignup_process
"
method=
"post"
>
<div
class=
"form-inline"
>
<div
class=
"input-area"
>
<span
class=
"input-label"
>
...
...
@@ -17,10 +17,10 @@
<div
class=
"input-area"
>
<span
class=
"input-label"
>
<label name="
Passwor
d">Password</label>
<label
name=
"
pw
d"
>
Password
</label>
</span>
<span
class=
"input-box"
>
<input type="text" name="
Passwor
d" >
<input
type=
"text"
name=
"
pw
d"
>
</span>
</div>
...
...
@@ -35,12 +35,13 @@
<div
class=
"input-area"
>
<span
class=
"input-label"
>
<label name="
male/female
">성별</label>
<label
name=
"
gender
"
>
성별
</label>
</span>
<select id="male/female" style="width: 200px; ">
<option>성별 선택</option>
<option>남자</option>
<option>여자</option>
<select
name=
"gender"
style=
"width: 200px; "
>
<optgroup
label=
"성별 선택"
>
<option
value=
"male"
>
남자
</option>
<option
value=
"female"
>
여자
</option>
</optgroup>
</select>
</div>
...
...
data/main.html
View file @
3b3fa69
...
...
@@ -41,7 +41,7 @@
<div
id =
"login-ing"
style=
"width:100%; text-align: center; margin-top: 5ch"
>
<div
class=
"form-inline"
>
<form
action=
"/login"
method=
"post"
>
<form
action=
"/login
_process
"
method=
"post"
>
<label>
ID
</label>
<input
type=
"text"
name=
"name"
class=
"form-control"
placeholder=
"홍길동"
style=
"width:200px;"
>
&
nbsp
&
nbsp
&
nbsp
&
nbsp
...
...
db.json
0 → 100644
View file @
3b3fa69
{
"users"
:
[
{
"ID"
:
"yooh3574"
,
"password"
:
"123"
,
"age"
:
"123"
,
"gender"
:
"male"
,
"height"
:
"123"
,
"weight"
:
"123"
}
]
}
\ No newline at end of file
lib/template.js
View file @
3b3fa69
module
.
exports
=
{
HTML
:
function
(
title
,
ch
,
line
,
body
){
HTML
:
function
(
title
,
ch
,
line
,
body
,
logout
){
return
`
<!DOCTYPE html>
<html lang="en">
...
...
@@ -31,6 +31,7 @@ module.exports = {
text-align: center;
color: white;
}
${
logout
}
</style>
${
line
}
...
...
main.js
View file @
3b3fa69
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
bodyParser
=
require
(
'body-parser'
);
var
helmet
=
require
(
'helmet'
)
app
.
use
(
helmet
());
var
session
=
require
(
'express-session'
);
var
FileStore
=
require
(
'session-file-store'
)(
session
);
var
template
=
require
(
'./lib/template.js'
);
var
url
=
'https://api.edamam.com/api/food-database/parser'
;
var
low
=
require
(
'lowdb'
)
var
FileSync
=
require
(
'lowdb/adapters/FileSync'
);
var
adapter
=
new
FileSync
(
'db.json'
);
var
db
=
low
(
adapter
);
db
.
defaults
({
users
:[]}).
write
();
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
app
.
use
(
bodyParser
.
json
());
app
.
use
(
session
({
secret
:
'asadlfkj!@#!@#dfgasdg'
,
resave
:
false
,
saveUninitialized
:
true
,
store
:
new
FileStore
()
}))
app
.
use
(
express
.
static
(
'data'
));
app
.
get
(
'/'
,
function
(
request
,
response
)
{
fs
.
readFile
(
'./contents/main'
,
function
(
error
,
body
){
fs
.
readFile
(
'./contents/main.html'
,
function
(
error
,
body
){
var
title
=
'Health Care'
;
var
ch
=
'15ch'
var
html
=
template
.
HTML
(
title
,
ch
,
''
,
body
);
var
html
=
template
.
HTML
(
title
,
ch
,
''
,
body
,
''
);
response
.
send
(
html
);
});
});
app
.
post
(
'/login_process'
,
function
(
request
,
response
)
{
var
post
=
request
.
body
;
var
ID
=
post
.
ID
;
var
password
=
post
.
pwd
;
var
user
=
db
.
get
(
'users'
).
find
({
ID
:
ID
,
password
:
password
}).
value
();
if
(
user
){
request
.
session
.
is_logined
=
true
;
request
.
session
.
save
(
function
(){
response
.
redirect
(
'/InputPage'
)
});
}
});
app
.
get
(
'/signup'
,
function
(
request
,
response
)
{
fs
.
readFile
(
'./contents/signup'
,
function
(
error
,
body
){
fs
.
readFile
(
'./contents/signup
.html
'
,
function
(
error
,
body
){
var
title
=
'Sign Up Page'
;
var
ch
=
'5ch'
var
html
=
template
.
HTML
(
title
,
ch
,
`<link rel="stylesheet" type="text/css" href="./a.css" />`
,
body
);
var
html
=
template
.
HTML
(
title
,
ch
,
`<link rel="stylesheet" type="text/css" href="./a.css" />`
,
body
,
''
);
response
.
send
(
html
);
});
});
app
.
post
(
'/signup_process'
,
function
(
request
,
response
)
{
var
post
=
request
.
body
;
var
ID
=
post
.
ID
;
var
pwd
=
post
.
pwd
;
var
age
=
post
.
age
;
var
gender
=
post
.
gender
;
var
height
=
post
.
height
;
var
weight
=
post
.
weight
;
db
.
get
(
'users'
).
push
({
ID
:
ID
,
password
:
pwd
,
age
:
age
,
gender
:
gender
,
height
:
height
,
weight
:
weight
}).
write
();
request
.
session
.
is_logined
=
true
;
request
.
session
.
ID
=
ID
;
request
.
session
.
save
(
function
(){
response
.
redirect
(
'/InputPage'
)
});
});
app
.
get
(
'/InputPage'
,
function
(
request
,
response
){
fs
.
readFile
(
'./contents/Input.html'
,
function
(
error
,
body
){
var
title
=
'Input Page'
;
var
ch
=
'5ch'
var
html
=
template
.
HTML
(
title
,
ch
,
``
,
body
,
`#logout{
position:absolute;
right: 20ch;
}`
);
response
.
send
(
html
);
});
});
app
.
get
(
'/logout'
,
function
(
request
,
response
)
{
request
.
session
.
destroy
(
function
(
err
){
response
.
redirect
(
'/'
);
})
});
app
.
listen
(
3000
,
function
()
{
console
.
log
(
'Example app listening on port 3000!'
)
});
\ No newline at end of file
});
\ No newline at end of file
...
...
sessions/eaaQvF4tffWqI4OAaU_Fhz-s6covIMoK.json
0 → 100644
View file @
3b3fa69
{
"cookie"
:{
"originalMaxAge"
:
null
,
"expires"
:
null
,
"httpOnly"
:
true
,
"path"
:
"/"
},
"__lastAccess"
:
1559789773873
}
\ No newline at end of file
Please
register
or
login
to post a comment