-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
52 lines (46 loc) · 1.07 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
const http = require('http')
const fs = require('fs')
const port = require('minimist')(process.argv.slice(2), {
default: { greeting: 'Hello' }
})
let homeContent = ''
let projectContent = ''
let registrationContent = ''
fs.readFile('home.html', (err, home) => {
if (err) {
throw err
}
homeContent = home
})
fs.readFile('project.html', (err, project) => {
if (err) {
throw err
}
projectContent = project
})
fs.readFile('registration.html', (err, registration) => {
if (err) {
throw err
}
registrationContent = registration
})
http
.createServer((request, response) => {
const url = request.url
response.writeHeader(200, { 'Content-Type': 'text/html' })
switch (url) {
case '/project':
response.write(projectContent)
response.end()
break
case '/registration':
response.write(registrationContent)
response.end()
break
default:
response.write(homeContent)
response.end()
break
}
})
.listen(port)