-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
36 lines (30 loc) · 852 Bytes
/
index.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
34
35
36
var fs = require('fs'),
express = require('express'),
app = express(),
Mock = require('mockjs');
app.get('/', function(req, res) {
fs.readFile(__dirname + '/index.html', 'utf8', function(err, text){
res.send(text);
});
});
//app.use(express.static('public'));
app.use('/dest', express.static('dest'));
app.post('/grid', function (req, res) {
var Random = Mock.Random,
data = Mock.mock({
'rows|10': [{
'id': '@integer(60, 1000)',
'name': '@cname',
'email': '@email',
'address': '@region',
'time': '@datetime(yyyy-MM-dd)'
}],
'total': 50
});
res.send( JSON.stringify(data, null, 4) );
});
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});