-
Notifications
You must be signed in to change notification settings - Fork 280
/
Copy pathhono.ts
29 lines (23 loc) · 868 Bytes
/
hono.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* @title Hono HTTP server
* @difficulty intermediate
* @tags cli, deploy
* @run -N <url>
* @resource {https://jsr.io/@hono/hono} Hono on jsr.io
* @resource {https://hono.dev/docs} Hono documentation
* @group Network
*
* 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