-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
33 lines (28 loc) · 911 Bytes
/
app.js
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
// file name :app.js
// create by guofw 2018-5-4
var express = require('express');
var app = express();
var bodyParse = require('body-parser')
var path = require('path');
app.use(bodyParse.urlencoded({extended:false})) ;
app.use(express.static(path.join(__dirname, 'public')));
// 处理根目录的get请求
app.get('/',function(req,res){
res.sendfile('public/main.html') ;
console.log('main page is required ');
}) ;
// 处理/login的get请求
app.get('/add', function (req,res) {
res.sendfile('public/add.html') ;
console.log('add page is required ') ;
}) ;
// 处理/Server的post请求
app.post('/buildserver',function(req,res){
console.log(req.body);
servername=req.body.servername ;
//这里写逻辑处理代码
console.log(servername) ;
res.json({"status":"success"});
});
// 监听3000端口
var server=app.listen(3000) ;