-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventSchedule.js
130 lines (98 loc) · 2.64 KB
/
eventSchedule.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
const url = require("url")
const http = require("http")
const { STATUS_CODES } = http
const {readFile: readFileAsync} = require("fs").promises
// const {readFileSync, readFile} = require("fs")
const {join} = require("path")
const PORT = process.env.PORT || 3000
const eventSchedule = `
<html>
<head>
<style>
body {
background-color: #fefae0;
}
</style>
<body>
<h1> Event Schedule </h1>
<h2><a href="registration" >Registration</a></p>
<h2><a href="speakers">Speaking Engagements</h2>
<h2><a href="breakout">Breakout Session</a></h2>
<h2><a href="party">After Party</a></h2>
<h4><a href="/" >Home</h4>
</body>
</html>
`
const registration = `
<html>
<head>
<style>
body {
background-color: #fefae0;
}
</style>
<body>
<h1>Register your interest for the event on this page</h1>
<h2>Name: </h2>
<h2>Payment Option: </h2>
<h4><a href="/" >Home</h4>
</body>
</html>
`
const party = `
<html>
<head>
<style>
body {
background-color: #fefae0;
}
</style>
<body>
<h1>Okayyyyy! </h1>
<h1>Let's PARTY & HAVE FUNNNNN!!!</h1>
<h4><a href="/" >Home</h4>
</body>
</html>
`
const eventScheduleListener = function (req, res) {
res.setHeader("Content-Type", "text/html")
if (req.method !== "GET") {
res.statusCode = 405
res.end(STATUS_CODES[res.statusCode] + `\r\n`)
return
}
const { pathname } = url.parse(req.url)
if (pathname === "/") {
res.end(eventSchedule)
return
}
if (pathname === "/registration") {
res.end(registration)
return
}
if (pathname === "/speakers") {
async function run () {
const contents = await readFileAsync("speakers.html")
await res.end(contents)
return
}
run().catch(console.error)
}
if (pathname === "/breakout") {
async function run () {
const fileName = join(__dirname, "breakout.html")
const contents = await readFileAsync(fileName)
await res.end(contents)
return
}
run().catch(console.error)
}
if (pathname === "/party") {
res.end(party)
return
}
// res.statusCode = 404
// res.end(STATUS_CODES[res.statusCode] + `\r\n`)
}
const server = http.createServer(eventScheduleListener)
server.listen(PORT)