-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
39 lines (29 loc) · 1.01 KB
/
app.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
const express = require('express')
const request = require('request')
var app = express()
app.use("/static", express.static(__dirname + "/static"))
app.set('view engine', 'ejs')
const PORT = process.env.PORT || 3000;
app.get('/', (req, res) => {
// res.render('index')
var districtData = ""
request('https://api.covid19india.org/state_district_wise.json',(err,res,body)=>{
districtData = JSON.parse(body)
})
request('https://api.covid19india.org/data.json', function (error, response, body) {
var stateData = JSON.parse(body)
var global = stateData.statewise[0]
var statedata = stateData.statewise
res.render('index',{data:{global:global,state:statedata,district:districtData}})
});
})
app.get('/policy',(req,res)=>{
res.render('policy')
})
app.get('/questions',(req,res)=>{
res.render('questions')
})
app.all('*', function(req, res) {
res.redirect('/');
});
app.listen(PORT, () => console.log(`Server is listening on port ${PORT}...`))