redhairedshanks1 commited on
Commit
0a2fe6c
·
verified ·
1 Parent(s): 529bb74

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -122,6 +122,11 @@ from services.s3_utils import upload_to_s3
122
  # === FastAPI Init ===
123
  api = FastAPI()
124
 
 
 
 
 
 
125
  # === Shared helpers ===
126
  def save_temp_file(file: UploadFile) -> str:
127
  tmp = tempfile.NamedTemporaryFile(delete=False)
@@ -162,7 +167,7 @@ async def extract_text_api(
162
  file: UploadFile = File(...),
163
  filename: str = Form(...),
164
  start_page: int = Form(...),
165
- end_page: int = Form(...)
166
  ):
167
  # cache = get_entry(filename) or {} # ❌ disabled
168
  path = save_temp_file(file)
@@ -178,7 +183,7 @@ async def extract_table_api(
178
  file: UploadFile = File(...),
179
  filename: str = Form(...),
180
  start_page: int = Form(...),
181
- end_page: int = Form(...)
182
  ):
183
  # cache = get_entry(filename) or {} # ❌ disabled
184
  path = save_temp_file(file)
@@ -191,4 +196,6 @@ async def extract_table_api(
191
 
192
  if __name__ == "__main__":
193
  import uvicorn
194
- uvicorn.run("app:api", host="0.0.0.0", port=7860, reload=True)
 
 
 
122
  # === FastAPI Init ===
123
  api = FastAPI()
124
 
125
+ # === Root Health Check ===
126
+ @api.get("/")
127
+ async def root():
128
+ return {"status": "ok", "message": "Space is running"}
129
+
130
  # === Shared helpers ===
131
  def save_temp_file(file: UploadFile) -> str:
132
  tmp = tempfile.NamedTemporaryFile(delete=False)
 
167
  file: UploadFile = File(...),
168
  filename: str = Form(...),
169
  start_page: int = Form(...),
170
+ end_page: int = Form(...),
171
  ):
172
  # cache = get_entry(filename) or {} # ❌ disabled
173
  path = save_temp_file(file)
 
183
  file: UploadFile = File(...),
184
  filename: str = Form(...),
185
  start_page: int = Form(...),
186
+ end_page: int = Form(...),
187
  ):
188
  # cache = get_entry(filename) or {} # ❌ disabled
189
  path = save_temp_file(file)
 
196
 
197
  if __name__ == "__main__":
198
  import uvicorn
199
+ # ⬇️ Removed reload=True (causing shutdowns in Hugging Face Spaces)
200
+ uvicorn.run("app:api", host="0.0.0.0", port=7860)
201
+