-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
38 lines (26 loc) · 854 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
const express = require('express');
const app = express()
const reg = require('./scrape/reg-number')
const predictPrice = require('./script/main')
const bodyParser = require('body-parser')
const port = process.env.PORT || 4000;
app.use(bodyParser.urlencoded({extended: false}));
app.use(express.static(__dirname + '/public'));
app.use(bodyParser.json());
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname + '/public/index.html'))
});
app.get('/regNumberDetails', async (req, res) => {
console.log(req.query.reg)
res.send(await reg(req.query.reg))
})
app.post('/predictPrice', async (req, res) => {
res.send({price: await predictPrice(req.body)})
})
app.get('/a', async (req, res) => {
console.log('called')
res.send({price: 'sa'})
})
app.listen(port, () => {
console.log('Server running on port' + port)
})