-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
48 lines (35 loc) · 1021 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
44
45
46
const express = require('express');
const path = require("path");
// const parseUrl = require('body-parser');
const getIndiaMartResults = require('./utils/indiamart');
const port = process.env.PORT || 4000;
const app = express()
// const encodeUrl = parseUrl.urlencoded({ extended: false })
const static_path = path.join(__dirname, "public");
app.use(express.static(static_path));
app.use(express.urlencoded({ extended: true }));
app.get('/', (req, res) => {
res.sendFile(__dirname + '/index.html')
})
app.get('/api/getCompanyDetails', (req, res) => {
let ss = req.query.ss;
let city = req.query.city;
getIndiaMartResults(ss, city)
.then(data => {
res.send({
data: data
})
})
.catch(error => {
res.send({
error: error
})
});
})
// app.post('/', (req, res) => {
// console.log('Form request:', req.body)
// res.sendStatus(200)
// })
app.listen(port, () => {
console.log(`Server is running at ${port}`);
})