vibe coding is the best
This commit is contained in:
@@ -2,14 +2,19 @@ import { readFileSync } from "fs";
|
||||
import { handleMessage, handleClose } from "./ws-handler";
|
||||
|
||||
const HTML = readFileSync("./src/public/index.html", "utf-8");
|
||||
const CSS = readFileSync("./src/public/styles.css", "utf-8");
|
||||
const JS = readFileSync("./src/public/script.js", "utf-8");
|
||||
|
||||
const server = Bun.serve({
|
||||
port: 3000,
|
||||
fetch(req, server) {
|
||||
if (new URL(req.url).pathname === "/ws") {
|
||||
const url = new URL(req.url);
|
||||
if (url.pathname === "/ws") {
|
||||
if (!server.upgrade(req)) return new Response("WS upgrade failed", { status: 400 });
|
||||
return undefined as any;
|
||||
}
|
||||
if (url.pathname === "/styles.css") return new Response(CSS, { headers: { "Content-Type": "text/css" } });
|
||||
if (url.pathname === "/script.js") return new Response(JS, { headers: { "Content-Type": "text/javascript" } });
|
||||
return new Response(HTML, { headers: { "Content-Type": "text/html; charset=utf-8" } });
|
||||
},
|
||||
websocket: {
|
||||
|
||||
Reference in New Issue
Block a user