-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (31 loc) · 926 Bytes
/
Copy pathserver.js
File metadata and controls
36 lines (31 loc) · 926 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
31
32
33
34
35
36
const express = require('express');
const app = express();
const path = require('path');
const router = express.Router();
const fs = require('fs');
app.get('/',function(req,res){
res.writeHead(200, {
'Content-Type': 'text/html'
});
fs.readFile('./principal.html', null, function (err, data) {
if (err) {
res.status(404).write('No encontre');
} else {
res.write(data);
}
res.end();
})
//__dirname : It will resolve to your project folder.
});
router.get('/descubre',function(req,res){
res.sendFile(path.join(__dirname+'/descubre.html'))
})
router.get('/KNNDataset',function(req,res){
console.log(path.join(__dirname+'/KNNDataset.json'))
res.sendFile(path.join(__dirname+'/KNNDataset.json'))
})
//add the router
app.use('/', router);
app.use("*/static", express.static('static'));
app.listen(process.env.port || 3000);
console.log('Running at Port 3000');