-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (23 loc) · 953 Bytes
/
index.js
File metadata and controls
29 lines (23 loc) · 953 Bytes
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
import https from '../index.js'
// Helpers
function html(message) {
return `<!doctype html><html lang='en'><head><meta charset='utf-8'/><title>Hello, world!</title><style>body{background-color: white; font-family: sans-serif;}</style></head><body><h1>${message}</h1></body></html>`
}
const headers = {'Content-Type': 'text/html'}
let options = {}
// For globally-trusted Let’s Encrypt certificates uncomment options.
// To provision certificates, also remove “staging: true” property.
// const os = require('os')
// options = {
// domains: [os.hostname()],
// staging: true
// }
// Create HTTPS server at https://localhost with locally-trusted certificates.
const server = https.createServer(options, (request, response) => {
// Respond to all routes with the same page.
response.writeHead(200, headers)
response.end(html('Hello, world!'))
})
server.listen(443, () => {
console.log(' 🎉 Server running on port 443.')
})