-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
43 lines (37 loc) · 1016 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
37
38
39
40
41
42
43
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const app = express();
const port = 5000;
const {uberScrapeHeader}=require('./uber');
//const {olaScrapeHeader}=require('./ola');
// Enable CORS for all routes
app.use(cors());
app.set('view engine', 'ejs');
app.use(express.static('public'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.get('/',(req,res)=>{
res.render('index');
})
// POST request for '/submit' endpoint
app.post('/Uberprice', express.json(), (req, res) => {
// Handle the POST request
const data = req.body;
// Handle the received data
console.log(data);
const result= uberScrapeHeader(data);
result.then(result=>{
res.json(result)
}).catch(err =>{
console.log(err);
})
});
// Handle other requests
app.use((req, res) => {
res.status(404).send('Not found');
});
// Start the server
app.listen(port, () => {
console.log(`Server listening on port ${port}`);
});