File size: 776 Bytes
2ea1736
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const express = require("express");
const path = require("path");
const app = express();
const PORT = process.env.PORT || 7860; // HF Spaces default

app.use(express.json());
app.use(express.static(path.join(__dirname, "public")));

// Spotify now-playing endpoint — gracefully returns not-playing when no Spotify token is available
app.get("/api/now-playing", (req, res) => {
  // On HF Spaces, the Spotify connector isn't available.
  // This endpoint exists so the frontend doesn't error — it just reports nothing playing.
  res.json({ playing: false });
});

// SPA fallback
app.get("*", (req, res) => {
  res.sendFile(path.join(__dirname, "public", "index.html"));
});

app.listen(PORT, "0.0.0.0", () => {
  console.log(`Collage Studio running on port ${PORT}`);
});