- Single executable
- Sandbox (env, fs, net, r/w)
- No
package.json
- No npm
- TypeScript
- ES6 modules
- No callbacks, Yes promises/async/await
Last active
April 12, 2020 16:24
-
-
Save ondras/da180377364bbfe5515051a24300ca4e to your computer and use it in GitHub Desktop.
Deno example
This file contains 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, ServerRequest } from "https://deno.land/std@master/http/server.ts"; | |
const body = "<img src=https://deno.land/images/deno_logo.png>"; | |
const port = Deno.args[0] || "8888"; | |
function processRequest(req: ServerRequest) { | |
req.respond({body}); | |
} | |
for await (const req of serve(`:${port}`)) { | |
processRequest(req); | |
} |
This file contains 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
#!/bin/sh | |
DENO=https://github.com/denoland/deno/releases/download/v0.40.0/deno-x86_64-unknown-linux-gnu.zip | |
FILE=https://gist.githubusercontent.com/ondras/da180377364bbfe5515051a24300ca4e/raw/991879cc34eefeaf327c3aed205e88dc6cbda3d6/01-server.ts | |
curl -L $DENO | gzip -d > deno | |
chmod +x deno | |
./deno --allow-net -r $FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment