http serverを立てる
localのHTMLファイルを動かす
code:sh
code:server.ts
const directory = Deno.args0; const app = createApp();
app.use(serveStatic(directory));
const port = 8899;
app.listen({ port });
console.log(Open http://localhost:${port});
実行用
code:sh
servestとJSXを併用するときは、deno-typesをReactの型に指定しないとType Errorだらけになるので注意してください code:jsx_server.tsx
const app = createApp();
app.handle("/", async (req) => {
await req.respond({
status: 200,
headers: new Headers({
"content-type": "text/html; charset=UTF-8",
}),
body: ReactDOMServer.renderToString(
<html>
<head>
<meta charSet="utf-8" />
<title>servest</title>
</head>
<body>Hello Servest!</body>
</html>,
),
});
});
app.listen({ port: 8888 });