-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
27 lines (22 loc) · 693 Bytes
/
app.js
File metadata and controls
27 lines (22 loc) · 693 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"use strict";
import http from 'http';
import express from "express";
import path from 'path';
import routes from './routes/index1';
const app = express();
app.set('port', process.env.PORT || 3001);
//静态资源 与 视图
app.use(express.static(path.join(__dirname, 'public')));
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// route set
routes(app);
app.use((req, res, next) => {
let err = new Error('Not Found');
err.status = 404;
next(err);
});
let server = http.createServer(app).listen(app.get('port'), () => {
let host = server.address().address;
console.log("服务启动成功,访问地址为 http://%s:%s", host, app.get('port'));
});