Skip to content

Instantly share code, notes, and snippets.

@danopia
Created September 5, 2023 14:21
Show Gist options
  • Save danopia/c3371d8348388bda33661a645b5a2204 to your computer and use it in GitHub Desktop.
Save danopia/c3371d8348388bda33661a645b5a2204 to your computer and use it in GitHub Desktop.
import { Server } from "https://deno.land/std@0.200.0/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