Created
August 20, 2017 10:57
-
-
Save ofanidariyan/dbe70daa4c03ad1cff8a863a75b2eca0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http2 = require('http2'); | |
const fs = require('fs'); | |
const hostname = '127.0.0.1'; | |
const port = 3000; | |
const options = { | |
key: fs.readFileSync('server.key'), | |
cert: fs.readFileSync('server.crt'), | |
requestCert: false, | |
rejectUnauthorized: false | |
}; | |
// Create a plain-text HTTP/2 server | |
const server = http2.createSecureServer(options); | |
server.on('stream', (stream, headers) => { | |
stream.respond({ | |
'content-type': 'text/html', | |
':status': 200 | |
}); | |
stream.end('Hello Word'); | |
}); | |
server.listen(port, hostname, () => { | |
console.log(`Server running at https://${hostname}:${port}/ !!!`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment