Toggle navigation
Toggle navigation
This project
Loading...
Sign in
최은석
/
ossw-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
채지성
2022-05-10 16:31:56 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6799f5f6e58dccaa94a1ded5960c394f99f7f47c
6799f5f6
1 parent
2ae3fac4
second
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
server.js
static/index.html → static/index.ejs
server.js
View file @
6799f5f
...
...
@@ -2,6 +2,10 @@
const
express
=
require
(
'express'
);
const
app
=
express
();
const
ejs
=
require
(
'ejs'
);
app
.
set
(
'view engine'
,
'ejs'
);
app
.
set
(
'views'
,
'./static'
);
const
bodyParser
=
require
(
'body-parser'
);
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
...
...
@@ -11,9 +15,17 @@ app.listen(8080, function () {
})
app
.
get
(
'/'
,
function
(
req
,
res
){
res
.
sendFile
(
__dirname
+
'/static/index.html'
)
res
.
render
(
'index.ejs'
,
{
items
:
items
});
})
let
items
=
[];
app
.
post
(
'/post'
,
function
(
req
,
res
){
console
.
log
(
req
);
let
item
=
req
.
body
.
text
;
console
.
log
(
item
);
if
(
item
!=
""
){
items
.
push
(
item
);}
console
.
log
(
"items"
,
items
);
res
.
render
(
'index.ejs'
,
{
items
:
items
});
});
\ No newline at end of file
...
...
static/index.
html
→
static/index.
ejs
View file @
6799f5f
...
...
@@ -4,10 +4,13 @@
<meta
charset=
"UTF-8"
>
</head>
<body>
<form
action=
"/post"
method=
"post"
name=
"ti"
>
<input
type=
"text"
>
<form
action=
"/post"
method=
"post"
>
<input
type=
"text"
name=
"text"
>
<button
type=
"submit"
>
submit
</button>
</form>
<div></div>
<
% items.forEach(function(item){ %>
<div>
<p>
<
%= item %>
</p></div>
<
% }); %>
</body>
</html>
\ No newline at end of file
...
...
Please
register
or
login
to post a comment