INNER CODE UNIT · Python
project_file
GenielabsOpenSource/spine-animation-ai · reskin-app/app/backend/server.py:176
def project_file(rel: str, v: Optional[str] = Query(None)):
"""Serve any file inside the open project (sandboxed to project.path).
Path-style URL (vs query param) so PixiJS / browser caches infer the file
type from the extension.
For .atlas files served with a ?v= cache-buster, rewrite the page-image
line(s) to include the same ?v= query. Spine atlases reference the PNG
by bare filename and the spine runtime resolves it against the atlas
URL — but URL resolution strips query strings, so without this rewrite
Pixi/the browser keep serving the pre-rebake PNG after inpaint/mask
edits even though the atlas itself reloads.
"""
project = _State.require_project()
full = (project.path / rel).resolve()
if not str(full).startswith(str(project.path.resolve())):
raise HTTPException(403, "path escapes project root")
if not full.is_file():