MCPcopy Create free account
hub / github.com/TomClive/SeeDance2Stitcher / handleRequest

Function handleRequest

server.js:1139–1158  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

1137}
1138
1139async function handleRequest(req, res) {
1140 const url = new URL(req.url, `http://${req.headers.host}`);
1141 if (req.method === "POST" && url.pathname === "/api/analyze") return handleAnalyze(req, res);
1142 if (req.method === "POST" && url.pathname === "/api/export") return handleExport(req, res);
1143 if (req.method === "POST" && url.pathname === "/api/export-collage") return handleExportCollage(req, res);
1144 if (req.method === "GET" && url.pathname === "/api/export-status") return handleExportStatus(req, res, url);
1145 if (req.method === "GET" && url.pathname === "/api/frame") return handleFrame(req, res, url);
1146 if (req.method === "GET" && url.pathname.startsWith("/media/")) {
1147 const [, , id, clip] = url.pathname.split("/");
1148 const session = sessions.get(id);
1149 if (!session) return text(res, 404, "Session not found");
1150 return serveFile(res, clip === "2" ? session.video2 : session.video1);
1151 }
1152 if (req.method === "GET" && url.pathname.startsWith("/outputs/")) {
1153 return serveFile(res, path.join(OUTPUTS, path.basename(url.pathname)));
1154 }
1155 const target = url.pathname === "/" ? path.join(PUBLIC, "index.html") : path.join(PUBLIC, path.normalize(url.pathname));
1156 if (!target.startsWith(PUBLIC)) return text(res, 403, "Forbidden");
1157 return serveFile(res, target);
1158}
1159
1160ensureDirs().then(() => {
1161 const port = Number(process.env.PORT || 4177);

Callers

nothing calls this directly

Calls 7

handleAnalyzeFunction · 0.85
handleExportFunction · 0.85
handleExportCollageFunction · 0.85
handleExportStatusFunction · 0.85
handleFrameFunction · 0.85
textFunction · 0.85
serveFileFunction · 0.85

Tested by

no test coverage detected