Viewing readonly version: 51View latest version
HTTP
99
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
const state = [];
export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
if (req.method == "POST" && url.pathname == "/api/board") {
const { grid, clickedCell }: { grid: number[][]; clickedCell: { x: number; y: number } } = await req.json();
console.log({ grid, clickedCell });
return Response.json({ updatedGrid: grid });
}
return new Response(
`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Grid Game</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<div id="root"></div>
<script type="module" src="${import.meta.resolve("./app")}"></script>
</body>
</html>
`,
{ headers: { "content-type": "text/html" } },
);
}
H
game