Spaces:
Sleeping
Sleeping
Update patch.py
Browse files
patch.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import os
|
| 2 |
|
| 3 |
-
patch =
|
| 4 |
from fastapi.staticfiles import StaticFiles
|
| 5 |
from fastapi.responses import FileResponse
|
| 6 |
import os as _os
|
|
@@ -13,21 +13,10 @@ if _os.path.exists(_static_dir):
|
|
| 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 |
content = content.replace(insert_after, insert_after + '\n' + patch)
|
| 21 |
open('backend/main.py', 'w').write(content)
|
| 22 |
-
print("
|
| 23 |
-
```
|
| 24 |
-
|
| 25 |
-
---
|
| 26 |
-
|
| 27 |
-
So your root files should now look like:
|
| 28 |
-
```
|
| 29 |
-
Dockerfile ← replaced
|
| 30 |
-
patch.py ← new file
|
| 31 |
-
backend/
|
| 32 |
-
frontend/
|
| 33 |
-
README.md
|
|
|
|
| 1 |
import os
|
| 2 |
|
| 3 |
+
patch = """
|
| 4 |
from fastapi.staticfiles import StaticFiles
|
| 5 |
from fastapi.responses import FileResponse
|
| 6 |
import os as _os
|
|
|
|
| 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 |
content = content.replace(insert_after, insert_after + '\n' + patch)
|
| 21 |
open('backend/main.py', 'w').write(content)
|
| 22 |
+
print("Patch applied successfully")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|