aboutsummaryrefslogtreecommitdiff
path: root/index.js
blob: e64fb0b2b1df0e3e79a8dcfba4079adab629b186 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

var fs = require('fs');
//express 
var express = require('express');
var app = express();
//this dir
var dir = __dirname;
const PORT=3000; 
let t = dir + './crates.json'
fs.readFile('./index.html', function (err, html) {
//listen
app.listen(PORT, function () {
    console.log('listening on port ' + PORT);
});
//on request serve index.html
app.get('/', function (req, res) {
    res.sendFile('index.html', {root: __dirname })
})
app.get('/crates.json', function (req, res) {
    res.sendFile('crates.json', {root: __dirname })
})
    
});