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();
|