-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
32 lines (25 loc) · 1009 Bytes
/
server.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
const express = require('express')
const logger = require('morgan')
const path = require('path')
const server = express()
server.use(express.urlencoded({'extended': true}))
server.use(logger('dev'))
// Routes
server.post('/cs212/homework/8/', (req, res) => {
madlib = ( `<h1>THE STORY </h1><p> THE ${req.body['adj1']} -ish ${req.body['noun1']} did the ${req.body['verb1']} on the ${req.body['adj2']} -ish ${req.body['noun2']} and then they all died the end. </p>` )
res.send(madlib)
})
server.post('/lightsout', (req,res) => {
res.send('/cs212/final')
})
// Setup static page serving for all the pages in "public"
const publicServedFilesPath = path.join(__dirname, 'public')
server.use(express.static(publicServedFilesPath))
// The server uses port 80 by default unless you start it with the extra
// command line argument 'local' like this:
// node server.js local
let port = 80
if (process.argv[2] === 'local') {
port = 8080
}
server.listen(port, () => console.log('Ready on localhost!'))