1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-29 02:29:06 -05:00
denoland-deno/http/http_bench.ts

22 lines
510 B
TypeScript
Raw Normal View History

2019-02-07 11:45:47 -05:00
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
2018-12-06 17:19:12 -05:00
import * as deno from "deno";
2019-02-15 11:03:57 -05:00
import { serve } from "./server.ts";
2018-12-06 17:19:12 -05:00
const addr = deno.args[1] || "127.0.0.1:4500";
const server = serve(addr);
const body = new TextEncoder().encode("Hello World");
async function main(): Promise<void> {
2019-02-15 11:03:57 -05:00
try {
for await (const request of server) {
await request.responder.respond({ status: 200, body });
}
} catch (e) {
console.log(e.stack);
console.error(e);
2018-12-06 17:19:12 -05:00
}
}
main();