-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
67 lines (53 loc) · 1.54 KB
/
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require("dotenv").config();
const express = require('express');
const app = express()
const multer = require("multer")
const upload = multer()
const bodyParser = require("body-parser")
//de parse application/json
app.use(bodyParser.json())
//de parse application/xwww-
app.use(bodyParser.urlencoded({extended: true}))
//de parse multipart/form-data
app.use(upload.array())
app.use(express.static('public'))
app.set('view engine', 'pug')
app.set('views', './views')
app.get("/", function(request, response){
response.render("form")
})
app.post("/", function(request, response){
console.log(request.body)
response.send("received your request")
})
app.get('/', function(request, response){
response.render("index")
})
app.get('/', function(request, response){
response.render("staticFile")
})
app.get('/aboutme',function(request, response){
response.render("aboutme", {
name: "About My",
url: "http://www.tutorialspoint.com"
})
})
app.get("/dairy",function(req,res){
res.sendFile(__dirname+"/dairy.html");
})
app.get('/contactme/myemail', function(request, response){
response.send("my email is [email protected]")
})
//Middleware function to log request protocol
app.use('/things', function(req, res, next){
console.log("A request for things received")
next();
});
// Route handler that sends the response
app.get('/things', function(req, res){
res.send('Things');
});
console.log(process.env.PORT ||3000);
app.listen(process.env.PORT||3000,()=>{
console.log("Server Running ")
})