Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
eue
Commits
f967f7cd
Commit
f967f7cd
authored
4 years ago
by
KangMin An
Browse files
Options
Download
Email Patches
Plain Diff
Add Data Input form, routes, routers, controls.
parent
e573eb20
master
kangmin
merger
premaster
who
yeni
yeni111
No related merge requests found
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
server/src/app.js
+9
-1
server/src/app.js
server/src/controllers/dataController.js
+8
-2
server/src/controllers/dataController.js
server/src/controllers/globalController.js
+3
-0
server/src/controllers/globalController.js
server/src/middlewares.js
+6
-0
server/src/middlewares.js
server/src/routers/dataRouter.js
+10
-0
server/src/routers/dataRouter.js
server/src/routers/globalRouter.js
+1
-1
server/src/routers/globalRouter.js
server/src/routes.js
+9
-0
server/src/routes.js
server/src/views/datainput.pug
+7
-0
server/src/views/datainput.pug
server/src/views/home.pug
+7
-1
server/src/views/home.pug
with
60 additions
and
5 deletions
+60
-5
server/src/app.js
View file @
f967f7cd
...
...
@@ -5,9 +5,12 @@ import morgan from "morgan";
import
helmet
from
"
helmet
"
;
import
path
from
"
path
"
;
import
routes
from
"
./routes
"
;
import
globalRouter
from
"
./routers/globalRouter
"
;
import
dataRouter
from
"
./routers/dataRouter
"
;
import
routes
from
"
./rout
es
"
;
import
{
localmiddleware
}
from
"
./middlewar
es
"
;
const
app
=
express
();
...
...
@@ -20,6 +23,11 @@ app.use(bodyParser.json());
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
app
.
use
(
morgan
(
"
dev
"
));
// local middleware 사용
app
.
use
(
localmiddleware
);
// router 사용
app
.
use
(
routes
.
home
,
globalRouter
);
app
.
use
(
routes
.
data
,
dataRouter
);
export
default
app
;
This diff is collapsed.
Click to expand it.
server/src/controllers/dataController.js
View file @
f967f7cd
export
const
getHome
=
(
req
,
res
)
=>
{
res
.
render
(
"
home
"
,
{
pagename
:
"
Home
"
});
import
routes
from
"
../routes
"
;
export
const
getDataInput
=
(
req
,
res
)
=>
{
res
.
render
(
"
datainput
"
,
{
pagename
:
"
Data Input
"
});
};
export
const
postDataInput
=
(
req
,
res
)
=>
{
res
.
redirect
(
routes
.
home
);
};
This diff is collapsed.
Click to expand it.
server/src/controllers/globalController.js
0 → 100644
View file @
f967f7cd
export
const
getHome
=
(
req
,
res
)
=>
{
res
.
render
(
"
home
"
,
{
pagename
:
"
Home
"
});
};
This diff is collapsed.
Click to expand it.
server/src/middlewares.js
0 → 100644
View file @
f967f7cd
import
routes
from
"
./routes
"
;
export
const
localmiddleware
=
(
req
,
res
,
next
)
=>
{
res
.
locals
.
routes
=
routes
;
next
();
};
This diff is collapsed.
Click to expand it.
server/src/routers/dataRouter.js
0 → 100644
View file @
f967f7cd
import
express
from
"
express
"
;
import
routes
from
"
../routes
"
;
import
{
getDataInput
,
postDataInput
}
from
"
../controllers/dataController
"
;
const
dataRouter
=
express
.
Router
();
dataRouter
.
get
(
routes
.
dataInput
,
getDataInput
);
dataRouter
.
post
(
routes
.
dataInput
,
postDataInput
);
export
default
dataRouter
;
This diff is collapsed.
Click to expand it.
server/src/routers/globalRouter.js
View file @
f967f7cd
import
express
from
"
express
"
;
import
routes
from
"
../routes
"
;
import
{
getHome
}
from
"
../controllers/
data
Controller
"
;
import
{
getHome
}
from
"
../controllers/
global
Controller
"
;
const
globalRouter
=
express
.
Router
();
...
...
This diff is collapsed.
Click to expand it.
server/src/routes.js
View file @
f967f7cd
// Global Routes
const
HOME
=
"
/
"
;
// Data Input
const
DATA
=
"
/data
"
;
const
DATA_INPUT
=
"
/input
"
;
const
DATA_OUTPUT
=
"
/output
"
;
const
routes
=
{
home
:
HOME
,
data
:
DATA
,
dataInput
:
DATA_INPUT
,
dataOutput
:
DATA_OUTPUT
,
};
export
default
routes
;
This diff is collapsed.
Click to expand it.
server/src/views/datainput.pug
0 → 100644
View file @
f967f7cd
block content
.form__container
form(action=routes.data+routes.dataInput, method = "post")
input(type="text", name="temp", require=true, placeholder="Temperature")
input(type="text", name="humi", require=true, placeholder="Humidity")
input(type="text", name="bri", require=true, placeholder="Brightness")
input(type="submit", value="Submit")
\ No newline at end of file
This diff is collapsed.
Click to expand it.
server/src/views/home.pug
View file @
f967f7cd
block content
h1 Hello! This is EUE Server.
\ No newline at end of file
.home-link_container
strong Efficient Usage of Electricity
ul
li
a(href=routes.data+routes.dataInput) 데이터 등록
li
a(href=routes.data+routes.dataOutput) 데이터 출력
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help