janpaul123-valle_tmp_8524715891926958662818742653551.web.val.run
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 serve an HTML page emulating a Hacker News clone.
// It uses plain HTML and CSS to create the frontend. Eventually,
// we can make it interactive with additional scripts.
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>Hacker News Clone</title>
<style>
body { font-family: Arial, sans-serif; margin: 0; padding: 0; background: #f6f6ef; }
#header { background: #ff6600; padding: 8px; }
#header a { color: black; font-size: 18px; text-decoration: none; font-weight: bold; }
.container { width: 85%; margin: auto; }
.story { padding: 8px 0; border-bottom: 1px solid #ccc; }
.story-title { font-size: 14px; }
.story-details { font-size: 10px; color: #666; }
</style>
</head>
<body>
<div id="header" class="container">
<a href="/">Hacker News Clone</a>
</div>
<div class="container">
<div class="story">
<div class="story-title"><a href="#">First Fake Story</a></div>
<div class="story-details">100 points by user1 1 hour ago | 50 comments</div>
</div>
<div class="story">
<div class="story-title"><a href="#">Second Fake Story</a></div>
<div class="story-details">150 points by user2 2 hours ago | 75 comments</div>
</div>
<div class="story">
<div class="story-title"><a href="#">Third Fake Story</a></div>
<div class="story-details">200 points by user3 3 hours ago | 100 comments</div>
</div>
</div>
</body>
</html>
`;
return new Response(htmlContent, {
headers: {
"Content-Type": "text/html",
},
});
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
July 17, 2024