Fix three code-extraction paths in an existing FastAPI and Playwright worker
Project brief
Need a focused repair to an existing Python FastAPI/Playwright worker that queries genspark.ai and extracts generated code. Keep the current synchronous/async endpoints, Redis queue/cookie persistence and response shape.
Three fixes: - Separate real HTML, JS, TS and Python code from explanatory prose, including pre/code blocks and Monaco editors. - Follow View into Files, traverse the file tree rather than only index.html, and read the selected files reliably. - Detect the alternative AI Developer result page and use the same extraction logic there.
Preserve the existing task polling, structured errors and saved-results behavior. Show code/response examples for each route, including a non-HTML file. The repository, authorized test account, permitted automation method and fixtures must be agreed before starting. No CAPTCHA, access-control or website-consent bypass. Please explain relevant Playwright/Monaco experience; this is not a new scraper or app.
Deliverables & acceptance
What you'll deliver
- Focused code changes for all three extraction routes, with reproduction/verification examples.
- Run instructions and evidence that existing endpoint response/error behavior is preserved.
What the result must meet
- Extract actual code, not prose, from agreed HTML/non-HTML and Monaco fixtures; file-tree route reads selected files beyond index.html.
- Alternative AI Developer route returns the same response structure; preserve sync/async polling and documented timeout/credential errors.