-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
51 lines (36 loc) · 1.35 KB
/
index.js
File metadata and controls
51 lines (36 loc) · 1.35 KB
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
49
50
const request = require("request");
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
const app = express()
const router = express.Router();
const fetch = require("node-fetch");
app.use('/images', express.static(__dirname + '/images'));
app.use('/css', express.static(__dirname + '/css'));
app.use('/js', express.static(__dirname + '/js'));
app.use(bodyParser.urlencoded({extended : true}));
app.use(express.static('public'));
router.get('/',function(req,res){
res.sendFile(path.join(__dirname+'/index.html'));
//__dirname : It will resolve to your project folder.
});
router.get('/pollution',function(req,res){
res.sendFile(path.join(__dirname+'/html/pollution.html'));
//__dirname : It will resolve to your project folder.
});
router.post('/pollution', function(req, res){
res.sendFile(path.join(__dirname+'/html/pollution.html'));
});
router.get('/help',function(req,res){
res.sendFile(path.join(__dirname+'/html/help.html'));
//__dirname : It will resolve to your project folder.
});
router.get('/contact',function(req,res){
res.sendFile(path.join(__dirname+'/html/contact.html'));
//__dirname : It will resolve to your project folder.
});
app.use('/', router);
const port = process.env.PORT || 3002
app.listen(port, ()=>{
console.log(`This server is running on ${port}`)
})