willthereader-testwebsite.web.val.run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from 'npm:react-dom/server';
export const testWebsite = (request: Request) => {
// convert to Response
return new Response(renderToString(
<html>
<head>
<title>Page Title</title>
</head>
<body>
<span style={{ color: "red" }}>H</span> <span style={{ color: "blue" }}>e</span>{" "}
<span style={{ color: "green" }}>l</span> <span style={{ color: "red" }}>l</span>{" "}
<span style={{ color: "green" }}>o</span>
</body>
</html>), {
headers: { 'Content-Type': 'text/html' }
}
);
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
v14
March 15, 2024