// server.js (minimal + echo) import express from 'express'; const PORT = process.env.PORT || 7860; const SPACE_ID = process.env.SPACE_ID || ''; const HOSTNAME = SPACE_ID ? `https://${SPACE_ID.replace(/\//g, '-').replace(/_/g, '-')}.hf.space` : '(local run)'; const app = express(); app.use(express.json()); // ← parse JSON bodies /* GET / : sanity ping */ app.get('/', (req, res) => { res.json({ ok: true, hostSeenByServer: req.headers.host, youHit: req.originalUrl, spaceId: SPACE_ID || null, }); }); /* POST /echo : return whatever JSON you sent */ app.post('/echo', (req, res) => { res.json({ received_at: new Date().toISOString(), body: req.body }); }); app.listen(PORT, '0.0.0.0', () => { console.log('🛰️ Public URL should be:', HOSTNAME); console.log('🚀 Echo test server listening on', PORT); });