Spaces:
Runtime error
Runtime error
David Li commited on
Commit ·
2853f16
1
Parent(s): f27fb5d
fix: try again
Browse files
app.py
CHANGED
|
@@ -11,22 +11,22 @@ from fastapi.middleware.cors import CORSMiddleware
|
|
| 11 |
app = FastAPI()
|
| 12 |
|
| 13 |
# load deta using
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
allow_methods=["*"],
|
| 23 |
-
allow_headers=["*"],
|
| 24 |
-
)
|
| 25 |
|
| 26 |
@app.get("/files")
|
| 27 |
async def get_files(exchange: str = "US"):
|
| 28 |
"""
|
| 29 |
"""
|
|
|
|
|
|
|
|
|
|
| 30 |
# get files in deta
|
| 31 |
result = drive.list()
|
| 32 |
all_files = result.get("names")
|
|
@@ -48,6 +48,9 @@ async def get_files(exchange: str = "US"):
|
|
| 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")
|
| 53 |
|
|
|
|
| 11 |
app = FastAPI()
|
| 12 |
|
| 13 |
# load deta using
|
| 14 |
+
|
| 15 |
+
# app.add_middleware(
|
| 16 |
+
# CORSMiddleware,
|
| 17 |
+
# allow_origins=["*"],
|
| 18 |
+
# allow_credentials=True,
|
| 19 |
+
# allow_methods=["*"],
|
| 20 |
+
# allow_headers=["*"],
|
| 21 |
+
# )
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
@app.get("/files")
|
| 24 |
async def get_files(exchange: str = "US"):
|
| 25 |
"""
|
| 26 |
"""
|
| 27 |
+
project_key = os.getenv("DETA_DRIVE_KEY")
|
| 28 |
+
deta = Deta(project_key)
|
| 29 |
+
drive = deta.Drive("stonk_events")
|
| 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 |
+
project_key = os.getenv("DETA_DRIVE_KEY")
|
| 52 |
+
deta = Deta(project_key)
|
| 53 |
+
drive = deta.Drive("stonk_events")
|
| 54 |
res = drive.get(id)
|
| 55 |
return StreamingResponse(res.iter_chunks(1024), media_type="application/pdf")
|
| 56 |
|