haenim

first

1 +{
2 + "name": "express-tutorial",
3 + "version": "1.0.0",
4 + "dependencies":
5 + {
6 + "express": "~4.13.1",
7 + "ejs": "~2.4.1"
8 + }
9 + }
...\ No newline at end of file ...\ No newline at end of file
1 +body{
2 + background-color: black;
3 + color: white;
4 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module.exports = function(app)
2 +{
3 + app.get('/',function(req,res){ //index.html 가져오기
4 + res.render('index.html')
5 + });
6 +}
1 +var express = require('express');
2 +var app = express();
3 +
4 +var router = require('./router/main')(app);// 라우터 모듈인 main.js 를 불러와서 app 에 전달해줍니다.
5 +app.set('views', __dirname + '/views'); //서버가 읽을 수 있도록 HTML 의 위치를 정의해줍니다.
6 +app.set('view engine', 'ejs'); //서버가 HTML 렌더링을 할 때, EJS 엔진을 사용하도록 설정합니다.
7 +app.engine('html', require('ejs').renderFile);
8 +
9 +var server = app.listen(3000, function(){
10 + console.log("Express server has started on port 3000")
11 +})
12 +
13 +app.use(express.static('public')); //css같은 거 사용
1 +<html>
2 + <head>
3 + <title>Main</title>
4 + <link rel="stylesheet" type="text/css" href="css/style.css">
5 + </head>
6 + <body>
7 + Hey, this is index page
8 + </body>
9 +</html>
...\ No newline at end of file ...\ No newline at end of file