Spaces:
Sleeping
Sleeping
Update server.js
Browse files
server.js
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// server.js – simplest health-check server
|
| 2 |
+
import express from 'express';
|
| 3 |
+
|
| 4 |
+
const PORT = process.env.PORT || 7860; // HF injects PORT=7860
|
| 5 |
+
const SPACE_ID = process.env.SPACE_ID || ''; // e.g. "simoncck/web_surf_api"
|
| 6 |
+
const HOSTNAME = SPACE_ID
|
| 7 |
+
? `https://${SPACE_ID.replace(/\//g, '-').replace(/_/g, '-')}.hf.space`
|
| 8 |
+
: '(local run)';
|
| 9 |
+
|
| 10 |
+
const app = express();
|
| 11 |
+
|
| 12 |
+
/* ------ root route: sanity check ------ */
|
| 13 |
+
app.get('/', (req, res) => {
|
| 14 |
+
res.json({
|
| 15 |
+
ok: true,
|
| 16 |
+
hostSeenByServer: req.headers.host,
|
| 17 |
+
youHit: req.originalUrl,
|
| 18 |
+
spaceId: SPACE_ID || null,
|
| 19 |
+
});
|
| 20 |
+
});
|
| 21 |
+
|
| 22 |
+
/* ------ start server ------ */
|
| 23 |
+
app.listen(PORT, '0.0.0.0', () => {
|
| 24 |
+
console.log('🛰️ Public URL should be:', HOSTNAME);
|
| 25 |
+
console.log('🚀 Simple test server listening on', PORT);
|
| 26 |
+
});
|