Spaces:
Sleeping
Sleeping
Delete patch.py
Browse files
patch.py
DELETED
|
@@ -1,30 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
|
| 3 |
-
patch = """
|
| 4 |
-
from fastapi.staticfiles import StaticFiles
|
| 5 |
-
from fastapi.responses import FileResponse
|
| 6 |
-
import os as _os
|
| 7 |
-
|
| 8 |
-
_static_dir = _os.path.join(_os.path.dirname(__file__), 'static')
|
| 9 |
-
if _os.path.exists(_static_dir):
|
| 10 |
-
app.mount('/assets', StaticFiles(directory=_os.path.join(_static_dir,'assets')), name='assets')
|
| 11 |
-
|
| 12 |
-
@app.get('/{full_path:path}')
|
| 13 |
-
async def serve_spa(full_path: str):
|
| 14 |
-
if full_path.startswith('analyze') or full_path.startswith('health'):
|
| 15 |
-
from fastapi import HTTPException
|
| 16 |
-
raise HTTPException(status_code=404, detail='Not found')
|
| 17 |
-
index = _os.path.join(_static_dir, 'index.html')
|
| 18 |
-
return FileResponse(index)
|
| 19 |
-
"""
|
| 20 |
-
|
| 21 |
-
content = open('backend/main.py').read()
|
| 22 |
-
insert_after = 'allow_headers=["*"],\n)'
|
| 23 |
-
|
| 24 |
-
if insert_after in content:
|
| 25 |
-
content = content.replace(insert_after, insert_after + '\n' + patch)
|
| 26 |
-
open('backend/main.py', 'w').write(content)
|
| 27 |
-
print("Patch applied successfully")
|
| 28 |
-
else:
|
| 29 |
-
print("WARNING: insert point not found - checking current content:")
|
| 30 |
-
print(content[200:600])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|