Created
June 5, 2020 18:19
-
-
Save jbergant/6a2b304c38e905a33f5b144e192ef189 to your computer and use it in GitHub Desktop.
deno server with env variables
This file contains hidden or 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 { serve } from "https://deno.land/std/http/server.ts"; | |
| const env = Deno.env.toObject(); | |
| const PORT = Number(env.PORT) || 8000; | |
| const HOST = env.HOST || "localhost"; | |
| const server = serve({ hostname: HOST, port: PORT }); | |
| console.log(`http://${HOST}:${PORT}`); | |
| for await (const req of server) { | |
| req.respond({ body: "Hello World\n" }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment