-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsim-server.js
More file actions
164 lines (146 loc) · 4.31 KB
/
Copy pathsim-server.js
File metadata and controls
164 lines (146 loc) · 4.31 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/**
* Minimal "Hello World" simulation server used as a test harness for split-screen mode.
* Started automatically by server.js when --examples flag is used.
* Can also be run standalone: node sim-server.js [port]
*/
const http = require('http');
const PORT = parseInt(process.env.SIM_PORT || process.argv[2] || '8080', 10);
const HTML = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hello World Simulation</title>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #0f172a;
color: #e2e8f0;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 2rem;
gap: 2rem;
}
.badge {
font-size: 0.7rem;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
padding: 0.25rem 0.75rem;
border-radius: 999px;
background: #1e3a5f;
color: #60a5fa;
border: 1px solid #2563eb44;
}
h1 {
font-size: clamp(1.8rem, 5vw, 3rem);
font-weight: 800;
background: linear-gradient(135deg, #60a5fa, #a78bfa, #f472b6);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
text-align: center;
line-height: 1.1;
}
p {
color: #94a3b8;
font-size: 1rem;
text-align: center;
max-width: 360px;
line-height: 1.6;
}
.card {
background: #1e293b;
border: 1px solid #334155;
border-radius: 12px;
padding: 1.5rem;
width: 100%;
max-width: 360px;
}
.card-title {
font-size: 0.75rem;
font-weight: 600;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #64748b;
margin-bottom: 1rem;
}
.stat-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.5rem 0;
border-bottom: 1px solid #1e293b;
font-size: 0.875rem;
}
.stat-row:last-child { border-bottom: none; }
.stat-label { color: #94a3b8; }
.stat-value { font-weight: 600; color: #e2e8f0; font-family: monospace; }
.stat-value.ok { color: #4ade80; }
.pulse {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
background: #4ade80;
box-shadow: 0 0 0 0 #4ade8080;
animation: pulse 2s infinite;
margin-right: 6px;
vertical-align: middle;
}
@keyframes pulse {
0% { box-shadow: 0 0 0 0 #4ade8080; }
70% { box-shadow: 0 0 0 8px #4ade8000; }
100% { box-shadow: 0 0 0 0 #4ade8000; }
}
#clock { font-family: monospace; color: #60a5fa; }
</style>
</head>
<body>
<span class="badge">● Simulation Running</span>
<h1>Hello World<br/>Simulation</h1>
<p>
This is a dummy simulation served by <code>sim-server.js</code>.
It proves split-screen reverse-proxy is working end-to-end.
</p>
<div class="card">
<div class="card-title">Runtime info</div>
<div class="stat-row">
<span class="stat-label">Status</span>
<span class="stat-value ok"><span class="pulse"></span>Online</span>
</div>
<div class="stat-row">
<span class="stat-label">Port</span>
<span class="stat-value">${PORT}</span>
</div>
<div class="stat-row">
<span class="stat-label">Proxied under</span>
<span class="stat-value">/sim/</span>
</div>
<div class="stat-row">
<span class="stat-label">Local time</span>
<span class="stat-value" id="clock">—</span>
</div>
</div>
<script>
const clock = document.getElementById('clock');
function tick() {
clock.textContent = new Date().toLocaleTimeString();
}
tick();
setInterval(tick, 1000);
</script>
</body>
</html>`;
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store' });
res.end(HTML);
});
server.listen(PORT, '127.0.0.1', () => {
// Signal to parent that we're ready (used by server.js spawn logic)
process.stdout.write(`sim-server listening on http://127.0.0.1:${PORT}\n`);
});