Deno: Hello world

遠端執行程式

遠端執行deno程式:deno run https://deno.land/std/examples/welcome.ts

Hello world 範例

// http.js
import { serve } from "https://deno.land/[email protected]/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");

for await (const req of s) {
  req.respond({ body: "Hello World\n" });
}
deno run http.js

由於需要提供網路權限,因此要使用:
deno run --allow-net http.js