-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (30 loc) · 909 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
const express = require('express');
const path = require('path');
const middleware = require('./middleware')
const middleware1 = require('./authorizeMiddleware');
const {people}= require('./data')
const app = express();
const PORT = 5000;
app.use(express.static('./public'))
app.use(express.urlencoded({extended:false}))
app.use('/about',[middleware,middleware1])
app.get('/',(req,res)=>{
console.log("response ")
//res.status(200).sendFile(path.resolve(__dirname,'./html/index.html'));
res.sendFile(path.resolve(__dirname,'./html/index.html'))
// res.send("home")
})
app.get('/about',(req,res)=>{
//console.log("response ")
res.send("about")
})
app.post('/login',(req,res)=>{
//req.query
res.send(req.body)
})
app.all('*',(req,res)=>{
req.status(404).send(`resourse not found`)
})
app.listen(PORT,()=>{
console.log(`app is listening on ${PORT}`)
})