1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-26 00:59:24 -05:00
denoland-deno/std/http/testdata/simple_https_server.ts

19 lines
553 B
TypeScript
Raw Normal View History

// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
// This is an example of a https server
import { serveTLS } from "../server.ts";
const tlsOptions = {
hostname: "localhost",
port: 4503,
certFile: "./http/testdata/tls/localhost.crt",
2019-12-02 19:14:25 -05:00
keyFile: "./http/testdata/tls/localhost.key"
};
const s = serveTLS(tlsOptions);
2019-12-02 19:14:25 -05:00
console.log(
`Simple HTTPS server listening on ${tlsOptions.hostname}:${tlsOptions.port}`
);
const body = new TextEncoder().encode("Hello HTTPS");
for await (const req of s) {
req.respond({ body });
}