slimshadow commited on
Commit
7ab93cb
·
verified ·
1 Parent(s): 79bbf46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -9
app.py CHANGED
@@ -1,14 +1,10 @@
1
- from fastapi import FastAPI, File, UploadFile
2
- from fastapi.responses import FileResponse
3
- import os
4
- import shutil
5
 
6
  app = FastAPI()
 
7
 
8
- # Directory to store uploaded files
9
- UPLOAD_DIR = "/app/uploads"
10
- os.makedirs(UPLOAD_DIR, exist_ok=True)
11
-
12
  @app.post("/upload/")
13
  async def upload_file(file: UploadFile = File(...)):
14
  file_path = os.path.join(UPLOAD_DIR, file.filename)
@@ -21,4 +17,4 @@ async def download_file(filename: str):
21
  file_path = os.path.join(UPLOAD_DIR, filename)
22
  if os.path.exists(file_path):
23
  return FileResponse(file_path, media_type='application/octet-stream', filename=filename)
24
- return {"error": "File not found"}
 
1
+ from fastapi import FastAPI
2
+ from fastapi.middleware.gzip import GZipMiddleware
 
 
3
 
4
  app = FastAPI()
5
+ app.add_middleware(GZipMiddleware, minimum_size=1000)
6
 
7
+ # Your existing routes
 
 
 
8
  @app.post("/upload/")
9
  async def upload_file(file: UploadFile = File(...)):
10
  file_path = os.path.join(UPLOAD_DIR, file.filename)
 
17
  file_path = os.path.join(UPLOAD_DIR, filename)
18
  if os.path.exists(file_path):
19
  return FileResponse(file_path, media_type='application/octet-stream', filename=filename)
20
+ return {"error": "File not found"}