-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (25 loc) · 683 Bytes
/
app.js
File metadata and controls
30 lines (25 loc) · 683 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
28
29
30
'use strict';
const http = require('http');
const url = require('url');
const express = require('express');
const app = express();
const config = require('./config');
const path = require('path');
const genToken = require('./lib/genToken');
app.use(express.static(path.join(__dirname, 'public')));
// app.get('/', function(req, res) {
// });
app.get('/token', function(req, res) {
res.writeHead(200, {
'Content-Type':'text/json',
'Expires': 0,
'Pragma': 'no-cache'
});
var retJson = {
uptoken: genToken()
}
res.end(JSON.stringify(retJson));
});
http.createServer(app).listen(config.port, function() {
console.log('server run at: ', config.port);
});