feat: Simplify Deno server root route and use environment greeting

This commit is contained in:
Mauricio Siu 2025-02-23 20:05:11 -06:00
parent bdb710ab43
commit cfdd6f5fdd

View File

@ -1,4 +1,3 @@
import { serveFile } from "jsr:@std/http/file-server";
const PORT = Deno.env.get("PORT") || 8000; const PORT = Deno.env.get("PORT") || 8000;
@ -6,7 +5,8 @@ const handler = async (req: Request): Promise<Response> => {
const url = new URL(req.url); const url = new URL(req.url);
if (url.pathname === "/") { if (url.pathname === "/") {
return await serveFile(req, "./public/index.html"); const greeting = Deno.env.get("GREETING") || "Hello from Deno 2!";
return new Response(greeting);
} else if (url.pathname === "/greet") { } else if (url.pathname === "/greet") {
const greeting = Deno.env.get("GREETING") || "Hello from Deno 2!"; const greeting = Deno.env.get("GREETING") || "Hello from Deno 2!";
return new Response(greeting); return new Response(greeting);