Spaces:
Sleeping
Sleeping
| import os | |
| patch = """ | |
| from fastapi.staticfiles import StaticFiles | |
| from fastapi.responses import FileResponse | |
| import os as _os | |
| _static_dir = _os.path.join(_os.path.dirname(__file__), 'static') | |
| if _os.path.exists(_static_dir): | |
| app.mount('/assets', StaticFiles(directory=_os.path.join(_static_dir,'assets')), name='assets') | |
| @app.get('/{full_path:path}') | |
| async def serve_spa(full_path: str): | |
| if full_path.startswith('analyze') or full_path.startswith('health'): | |
| from fastapi import HTTPException | |
| raise HTTPException(status_code=404, detail='Not found') | |
| index = _os.path.join(_static_dir, 'index.html') | |
| return FileResponse(index) | |
| """ | |
| content = open('backend/main.py').read() | |
| insert_after = 'allow_headers=["*"],\n)' | |
| if insert_after in content: | |
| content = content.replace(insert_after, insert_after + '\n' + patch) | |
| open('backend/main.py', 'w').write(content) | |
| print("Patch applied successfully") | |
| else: | |
| print("WARNING: insert point not found - checking current content:") | |
| print(content[200:600]) |