-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandler.js
29 lines (29 loc) · 927 Bytes
/
handler.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
const fs=require('fs');
function favicon(resp,params){
resp.writeHead(200, {'Content-Type':'text/html;charset=UTF-8'});
fs.createReadStream(__dirname +'/favicon.ico').pipe(resp);
}
function index(resp,params){
resp.writeHead(200, {'Content-Type':'text/html;charset=UTF-8'});
fs.createReadStream(__dirname +'/index.html','utf8').pipe(resp);
}
function products(resp,params){
resp.writeHead(200, {'Content-Type':'text/html;charset=UTF-8'});
fs.createReadStream(__dirname +'/products.html','utf8').pipe(resp);
}
function detail(resp,params){
resp.writeHead(200, {'Content-Type':'text/html;charset=UTF-8'});
fs.createReadStream(__dirname +'/detail.html','utf8').pipe(resp);
}
function api(resp,params){
resp.writeHead(200, {'Content-Type':'application/json'});
var obj=JSON.stringify(params);
resp.end(obj)
}
module.exports={
index:index,
products:products,
detail:detail,
api:api,
favicon:favicon
}