'Express: how to render static files from a specific route
app.js
import express from "express";
import { getTokenData } from "./src/services/dbServices";
const app = express();
app.get("/api/token/:token_id", (req, res) => {
const tokenId = req.params.token_id;
const worldMetadata = getTokenData(tokenId).metadata;
res.send(worldMetadata);
});
app.use(express.static("public"));
app.get("/api/animation/:token_id", (req, res) => {});
app.listen(5000, () => {
console.log("App running on port 5000");
});
Im trying to render static files from my server to display a p5.j script. right now the public directory is being rendered from the "/" route of my server thanks to the express.static. I'd like to render the public directory only when the url matches /api/animation/:token_id. I've been trying for hours to make this work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
