-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
48 lines (38 loc) · 1.16 KB
/
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
43
44
45
46
47
48
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
// app.use(express.static('/public'));
const path = require('path')
let cors = require('cors')
app.use(cors())
console.log(__dirname);
console.log(path.join(__dirname,"/public"));
const staticPath = path.join(__dirname,"/public")
app.use(express.static(staticPath))
app.use((req,res,next)=>{
res.setHeader('Access-Control-Allow-Origin','*');
res.setHeader('Access-Control-Allow-Methods','GET,POST,PUT,PATCH,DELETE');
res.setHeader('Access-Control-Allow-Methods','Content-Type','Authorization');
next();
})
app.use(express.json())
var requestAmbulance = false;
var userConfirmation = false;
app.get('/requestAmbulance',(req,res)=>{
res.send(requestAmbulance);
})
app.post('/confirmAmbulance',(req,res)=>{
requestAmbulance = true;
res.send(requestAmbulance);
})
app.post('/confirmUser',(req,res)=>{
userConfirmation = true;
res.send(userConfirmation);
})
app.get('/userConfirmation',(req,res)=>{
res.send(userConfirmation);
})
const PORT = process.env.PORT || 8080;
app.listen(PORT, ()=>{
console.log(`Server is running on PORT ${PORT}`)
})