Spaces:
Sleeping
Sleeping
Update patch.py
Browse files
patch.py
CHANGED
|
@@ -11,12 +11,20 @@ if _os.path.exists(_static_dir):
|
|
| 11 |
|
| 12 |
@app.get('/{full_path:path}')
|
| 13 |
async def serve_spa(full_path: str):
|
|
|
|
|
|
|
|
|
|
| 14 |
index = _os.path.join(_static_dir, 'index.html')
|
| 15 |
return FileResponse(index)
|
| 16 |
"""
|
| 17 |
|
| 18 |
content = open('backend/main.py').read()
|
| 19 |
insert_after = 'allow_headers=["*"],\n)'
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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])
|