David Li commited on
Commit
2853f16
·
1 Parent(s): f27fb5d

fix: try again

Browse files
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -11,22 +11,22 @@ from fastapi.middleware.cors import CORSMiddleware
11
  app = FastAPI()
12
 
13
  # load deta using
14
- project_key = os.getenv("DETA_DRIVE_KEY")
15
- deta = Deta(project_key)
16
- drive = deta.Drive("stonk_events")
17
-
18
- app.add_middleware(
19
- CORSMiddleware,
20
- allow_origins=["*"],
21
- allow_credentials=True,
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