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
53
// 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; /* Ensures the cat doesn't overflow */
}
h1 {
color: #61dafb;
animation: colorChange 3s infinite;
}
@keyframes colorChange {
0% { color: #61dafb; }
50% { color: #ff6f61; }
100% { color: #61dafb; }
}
.cat {
position: absolute;
bottom: 0;
left: 0;
width: 100px;
animation: moveCat 10s linear infinite;
}
@keyframes moveCat {
0% { transform: translate(0, 0); }
25% { transform: translate(300px, 0); }
50% { transform: translate(300px, -300px); }
75% { transform: translate(0, -300px); }
100% { transform: translate(0, 0); }
}
</style>
</head>
<body>
<h1>Hello, world!</h1>
<img class="cat" src="https://media.giphy.com/media/JIX9t2j0ZTN9S/giphy.gif" alt="Cat"/>
</body>
</html>
`;
return new Response(html, { headers: { "Content-Type": "text/html" } });
}
janpaul123-valle_tmp_6579538930770234611834582082941192.web.val.run
July 15, 2024