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
45
46
47
48
49
50
51
52
// This val will respond to any request with an HTML "Hello, world!" message with some fun CSS styles and an animated cat
export default async function(req: Request): Promise<Response> {
const html = `
<html>
<head>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #282c34;
color: white;
font-family: Arial, sans-serif;
font-size: 2em;
text-align: center;
overflow: hidden;
}
h1 {
color: #61dafb;
animation: colorChange 3s infinite;
z-index: 1;
}
@keyframes colorChange {
0% { color: #61dafb; }
50% { color: #ff6f61; }
100% { color: #61dafb; }
}
.cat {
position: absolute;
animation: moveCat 10s infinite linear;
height: 100px;
}
@keyframes moveCat {
0% { transform: translate(0, 0); }
25% { transform: translate(80vw, 0); }
50% { transform: translate(80vw, 80vh); }
75% { transform: translate(0, 80vh); }
100% { transform: translate(0, 0); }
}
</style>
</head>
<body>
<h1>Hello, world!</h1>
<img src="https://i.imgur.com/JX4AR1D.png" class="cat" />
</body>
</html>
`;
return new Response(html, { headers: { "Content-Type": "text/html" } });
}
janpaul123-valle_tmp_86768439956087117587941274446584.web.val.run
July 15, 2024