-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.js
More file actions
37 lines (34 loc) · 1.03 KB
/
Copy pathapp.js
File metadata and controls
37 lines (34 loc) · 1.03 KB
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
28
29
30
31
32
33
34
35
36
37
/**
* node核心模块
*/
var express = require('express');
var path = require('path');
var ejs = require('ejs');
var app = express();
/**
* 我们的处理模块 依次是 主页 文档服务器相关 权限服务器相关
*/
var index = require('./routes/index');
var verify = require('./routes/verify');
/* 视图模板配置 */
//app.set('views', __dirname + '/views'); //jade写法
//app.set('views engine', 'jade');
app.engine('.html', ejs.__express); //html写法
app.set('view engine', 'html');
/**
* 中间件配置
*/
app.use(express.static(path.join(__dirname, '/public')));
app.use(express.static(path.join(__dirname, '/')));//为了在html中可以直接查找相关文件,以便修改
app.use('/', index);
app.use('/verify', verify);
//其他未处理路由 返回404页面
app.get('*', function (req, res) {
res.render('error.html', { //? html可以这么传参数吗?
title: 'No Found'
})
})
/* 端口监听 */
app.listen(8080, function () {
console.log("listening on 8080")
});