deno.com

Hono HTTP server

在 Github 上编辑

An example of a HTTP server that uses the Hono framework.

Import the Hono framework
import { Hono } from "jsr:@hono/hono";
Create a new Hono server
const app = new Hono();
Define a route that responds with "Hello, World!" The first argument is the path, the second is the request handler
app.get("/", (c) => c.text("Hello, World!"));
Call Deno.serve with the request handler to start the server on the default port (8000)
Deno.serve(app.fetch);
Test the server with: curl http://localhost:8000 Should output "Hello, World!"
Read more about Hono with Deno at https://hono.dev/docs/getting-started/deno

使用 Deno CLI 在本地运行 此示例

deno run --allow-net https://docs.denohub.com/examples/scripts/hono.ts

你找到需要的内容了吗?

隐私政策