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
45
46
// This script creates an HTTP val that responds with "Hello World" using some CSS styling to make it look cool.
// We'll set up a basic HTML structure and use internal CSS to style the text.
/**
* This function handles incoming HTTP requests and returns a styled HTML response.
*/
export default function(req: Request): Response {
// The CSS styles we will apply
const css = `
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: linear-gradient(to right, #ff7e5f, #feb47b);
margin: 0;
font-family: 'Arial', sans-serif;
}
h1 {
font-size: 4rem;
color: white;
text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}
`;
// The HTML content
const html = `
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>${css}</style>
<title>Hello World</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
`;
// Returning the response as an HTML document
return new Response(html, {
headers: { "Content-Type": "text/html" },
});
}