Skip to content

Instantly share code, notes, and snippets.

@davydkov
Created April 15, 2022 23:48
Show Gist options
  • Save davydkov/3d34d51a9dfb5af364e6c9b56f2b58a2 to your computer and use it in GitHub Desktop.
Save davydkov/3d34d51a9dfb5af364e6c9b56f2b58a2 to your computer and use it in GitHub Desktop.
/** @jsx h */
/// <reference no-default-lib="true"/>
/// <reference lib="dom" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { h, renderSSR } from "https://deno.land/x/[email protected]/mod.ts";
function App() {
return (
<html>
<head>
<title>Hello from JSX</title>
</head>
<body>
<h1>Hello world</h1>
</body>
</html>
);
}
function handler(req) {
const html = renderSSR(<App />);
return new Response(html, {
headers: {
"content-type": "text/html",
},
});
}
console.log("Listening on http://localhost:8000");
serve(handler);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment