Spaces:
Runtime error
Runtime error
David Li commited on
Commit ·
8ca5d50
1
Parent(s): b9b9298
fix: again
Browse files
main.py
CHANGED
|
@@ -10,6 +10,9 @@ from fastapi.middleware.cors import CORSMiddleware
|
|
| 10 |
app = FastAPI()
|
| 11 |
|
| 12 |
# load deta using
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
app.add_middleware(
|
| 15 |
CORSMiddleware,
|
|
@@ -23,9 +26,7 @@ app.add_middleware(
|
|
| 23 |
async def get_files(exchange: str = "US"):
|
| 24 |
"""
|
| 25 |
"""
|
| 26 |
-
|
| 27 |
-
deta = Deta(project_key)
|
| 28 |
-
drive = deta.Drive("stonk_events")
|
| 29 |
# get files in deta
|
| 30 |
result = drive.list()
|
| 31 |
all_files = result.get("names")
|
|
@@ -47,8 +48,5 @@ async def get_files(exchange: str = "US"):
|
|
| 47 |
# reason it was likely failing is because of the response size limit
|
| 48 |
@app.get("/file/{id}")
|
| 49 |
async def get_file(id: str):
|
| 50 |
-
project_key = os.getenv("DETA_DRIVE_KEY")
|
| 51 |
-
deta = Deta(project_key)
|
| 52 |
-
drive = deta.Drive("stonk_events")
|
| 53 |
res = drive.get(id)
|
| 54 |
return StreamingResponse(res.iter_chunks(1024), media_type="application/pdf")
|
|
|
|
| 10 |
app = FastAPI()
|
| 11 |
|
| 12 |
# load deta using
|
| 13 |
+
project_key = os.getenv("DETA_DRIVE_KEY")
|
| 14 |
+
deta = Deta(project_key)
|
| 15 |
+
drive = deta.Drive("stonk_events")
|
| 16 |
|
| 17 |
app.add_middleware(
|
| 18 |
CORSMiddleware,
|
|
|
|
| 26 |
async def get_files(exchange: str = "US"):
|
| 27 |
"""
|
| 28 |
"""
|
| 29 |
+
|
|
|
|
|
|
|
| 30 |
# get files in deta
|
| 31 |
result = drive.list()
|
| 32 |
all_files = result.get("names")
|
|
|
|
| 48 |
# reason it was likely failing is because of the response size limit
|
| 49 |
@app.get("/file/{id}")
|
| 50 |
async def get_file(id: str):
|
|
|
|
|
|
|
|
|
|
| 51 |
res = drive.get(id)
|
| 52 |
return StreamingResponse(res.iter_chunks(1024), media_type="application/pdf")
|