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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// This script will respond with a basic HTML page, including styled content, using the built-in Response class in TypeScript.
/**
* HTTP Val: Hello World Example (HTML Response with CSS)
*
* This script will respond with a basic HTML page that says "Hello world" to any incoming HTTP request, and includes some cool CSS styles.
*/
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>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: linear-gradient(to right, #ff7e5f, #feb47b);
font-family: Arial, sans-serif;
color: white;
}
h1 {
font-size: 4rem;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
</style>
</head>
<body>
<h1>Hello world</h1>
</body>
</html>
`;
return new Response(htmlContent, {
headers: { "Content-Type": "text/html" },
});
}
janpaul123-valle_tmp_137659959713258178037932973670666.web.val.run
July 15, 2024