Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
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
28
// This script will respond with a basic HTML page instead of plain text using the built-in Response class in TypeScript.
/**
* HTTP Val: Hello World Example (HTML Response)
*
* This script will respond with a basic HTML page that says "Hello world" to any incoming HTTP request.
*/
export default async function(req: Request): Promise<Response> {
const htmlContent = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello World</title>
</head>
<body>
<h1>Hello world</h1>
</body>
</html>
`;
return new Response(htmlContent, {
headers: { "Content-Type": "text/html" },
});
}
janpaul123-valle_tmp_0795929485980921815770770417569246.web.val.run
July 15, 2024