【发布时间】:2020-05-15 02:19:43
【问题描述】:
在Deno 运行时使用以下简单的TypeScript 代码:
import { serve } from "https://deno.land/std@v0.24.0/http/server.ts"
async function main() {
const body = new TextEncoder().encode("Hello World\n");
let port = 8000
const s = serve({ port: port });
console.log(`Server had been started at:
http://localhost:${port}/`);
for await (const req of s) {
req.respond({ body });
}
};
main()
通过运行来执行:
D:\repos\deno>deno --allow-net main.ts
Compile file:///D:/repos/deno/main.ts
Server had been started at:
http://localhost:8000/
正在浏览器中显示Hello World。
有没有办法显示 HTML 元素而不是文本,例如显示 <h1> 或 <button>
【问题讨论】:
标签: deno