Created
October 3, 2024 20:42
-
-
Save rglover/069bdaea91c629e95957610b484ed82c to your computer and use it in GitHub Desktop.
Parrot Example
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 express = require('express'); | |
const http2 = require('http2'); | |
const fs = require('fs'); | |
const app = express(); | |
app.get('/', (req, res) => { | |
res.send('Hello, HTTP/2 World!'); | |
}); | |
const options = { | |
key: fs.readFileSync('path/to/private-key.pem'), | |
cert: fs.readFileSync('path/to/certificate.pem') | |
}; | |
const server = http2.createSecureServer(options, app); | |
const port = 3000; | |
server.listen(port, () => { | |
console.log(`HTTP/2 server running on https://localhost:${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment