Add Hello World test application for Hostityourself
Includes a Node.js HTTP server, static HTML page, and Dockerfile for containerized self-hosting. Exposes a /health endpoint for platform health checks. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
521d86e50d
4 changed files with 80 additions and 0 deletions
7
Dockerfile
Normal file
7
Dockerfile
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
FROM node:20-alpine
|
||||
WORKDIR /app
|
||||
COPY package.json .
|
||||
COPY server.js .
|
||||
COPY index.html .
|
||||
EXPOSE 3000
|
||||
CMD ["node", "server.js"]
|
||||
34
index.html
Normal file
34
index.html
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<!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 {
|
||||
font-family: system-ui, sans-serif;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
background: #f0f4f8;
|
||||
}
|
||||
.card {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
padding: 2rem 3rem;
|
||||
box-shadow: 0 4px 16px rgba(0,0,0,0.1);
|
||||
text-align: center;
|
||||
}
|
||||
h1 { color: #2d3748; margin: 0 0 0.5rem; }
|
||||
p { color: #718096; margin: 0; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="card">
|
||||
<h1>Hello, World!</h1>
|
||||
<p>Test application for Hostityourself</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
9
package.json
Normal file
9
package.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "helloworld",
|
||||
"version": "1.0.0",
|
||||
"description": "Hello World test app for Hostityourself",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"start": "node server.js"
|
||||
}
|
||||
}
|
||||
30
server.js
Normal file
30
server.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
const http = require('http');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
if (req.url === '/' || req.url === '/index.html') {
|
||||
const filePath = path.join(__dirname, 'index.html');
|
||||
fs.readFile(filePath, (err, data) => {
|
||||
if (err) {
|
||||
res.writeHead(500);
|
||||
res.end('Error loading page');
|
||||
return;
|
||||
}
|
||||
res.writeHead(200, { 'Content-Type': 'text/html' });
|
||||
res.end(data);
|
||||
});
|
||||
} else if (req.url === '/health') {
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ status: 'ok' }));
|
||||
} else {
|
||||
res.writeHead(404);
|
||||
res.end('Not found');
|
||||
}
|
||||
});
|
||||
|
||||
server.listen(PORT, () => {
|
||||
console.log(`Server running on http://localhost:${PORT}`);
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue