迪诺运行不正常也喝酒 [英] Deno run is not working properly also drun
问题描述
创建了index.ts并编写了简单的代码以侦听端口3000并在主体上打印hello world之后,我也无法运行或从deno的 drun 模块获取输出
After created an index.ts and wrote a simple code for listening to port 3000 and printing hello world on the body, I'm also not able to run or get the output from deno's drun module.
import { Application, Router } from "https://deno.land/x/denotrain@v0.5.0/mod.ts";
const app = new Application();
const router = new Router();
// Middleware
app.use((ctx) => {
ctx.cookies["user.session"] = "qwertz";
ctx.cookies["a"] = "123";
ctx.cookies["b"] = "456";
delete ctx.cookies["user.session"];
return;
});
router.get("/", (ctx) => {
return new Promise((resolve) => resolve("This is the admin interface!"));
});
router.get("/edit", async (ctx) => {
return "This is an edit mode!";
});
app.get("/", (ctx) => {
return {"hello": "world"};
});
app.use("/admin", router);
app.get("/:id", (ctx) => {
// Use url parameters
return "Hello World with ID: " + ctx.req.params.id
});
return ctx.req.body;
});
await app.run()
推荐答案
开发环境:-Windows 10
Development Environment:- Windows 10
问题似乎是地址 0.0.0.0 仅用于 mac .Windows不使用 0.0.0.0 地址.
The problem seems to be the address 0.0.0.0 is specific to mac only.Windows Doesn't use 0.0.0.0 address.
转到 localhost:3000/127.0.0.1:3000 之后.我能够得到输出.我认为也许Windows将 0.0.0.0 重定向到本地主机.无论如何,它解决了我的问题!
After going to localhost:3000 / 127.0.0.1:3000. I was able to get the output.I think maybe Windows redirects the 0.0.0.0 to localhost. Anyway it solved my problem!
这篇关于迪诺运行不正常也喝酒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!