-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
43 lines (33 loc) · 843 Bytes
/
server.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
37
38
39
40
41
42
"use strict";
const express = require('express');
const app = express();
const path = require('path');
const fs = require('fs');
const cron = require('node-cron');
const saveToDB = require('./helpers/dbSave');
saveToDB();
cron.schedule('* * 6 * * *', function() {
saveToDB();
});
app.use('/public', express.static(path.join(__dirname, "public")));
app.get('/', function(req, res) {
fs.readFile('views/login.html', function (err, data) {
res.writeHead(200, {
"Content-Type": "text/html"
});
res.write(data);
res.send();
});
})
app.get('/currency', function(req, res) {
fs.readFile('views/home.html', function (err, data) {
res.writeHead(200, {
"Content-Type": "text/html"
});
res.write(data);
res.send();
});
})
app.listen(8080, () => {
console.log('static server starts on port 8080');
})