Created
September 5, 2023 14:21
-
-
Save danopia/c3371d8348388bda33661a645b5a2204 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
import { Server } from "https://deno.land/[email protected]/http/server.ts"; | |
const port = 4505; | |
const handler = (request: Request) => { | |
const body = `Your user-agent is:\n\n${request.headers.get( | |
"user-agent", | |
) ?? "Unknown"}`; | |
return new Response(body, { status: 200 }); | |
}; | |
const server = new Server({ host: '0.0.0.0', port, handler }); | |
const certFile = "cert.pem"; | |
const keyFile = "key.pem"; | |
console.log("server listening on https://localhost:4505"); | |
await server.listenAndServeTls(certFile, keyFile); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment