-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
46 lines (32 loc) · 1017 Bytes
/
script.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
const express = require("express");
const path = require("path");
const fs = require("fs");
const app = express();
const port = 80;
const mongoose = require('mongoose');
const home = fs.readFileSync('index.html')
const contact = fs.readFileSync('./contact.html')
// EXPRESS SPECIFIC STUFF
app.use('/static', express.static('./css')) // For serving static files
app.use(express.urlencoded())
// PUG SPECIFIC STUFF
// app.set('view engine', 'pug') // Set the template engine as pug
// app.set('views', path.join(__dirname, 'views')) // Set the views directory
// ENDPOINTS
app.get('/', (req, res)=>{
res.end(home)
res.status(200).render('../index.html')
})
app.get('/contact', (req, res)=>{
res.end(contact)
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
// app.post('/', (req, res)=>{
// name = req.body.name
// age = req.body.age
// gender = req.body.gender
// address = req.body.address
// more = req.body.more
// }