Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,10 +3,17 @@ from fastapi.responses import HTMLResponse
|
|
| 3 |
import shutil
|
| 4 |
from inference import process_document
|
| 5 |
# from json_handling import process_whole_doc
|
| 6 |
-
|
| 7 |
|
| 8 |
app = FastAPI()
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
@app.get("/", response_class=HTMLResponse)
|
| 11 |
def root():
|
| 12 |
return """
|
|
|
|
| 3 |
import shutil
|
| 4 |
from inference import process_document
|
| 5 |
# from json_handling import process_whole_doc
|
| 6 |
+
from model_loader import get_model
|
| 7 |
|
| 8 |
app = FastAPI()
|
| 9 |
|
| 10 |
+
@app.on_event("startup")
|
| 11 |
+
def startup_event():
|
| 12 |
+
print("Starting application...")
|
| 13 |
+
print("Loading model before API becomes ready...")
|
| 14 |
+
get_model()
|
| 15 |
+
print("Startup complete. API is ready.")
|
| 16 |
+
|
| 17 |
@app.get("/", response_class=HTMLResponse)
|
| 18 |
def root():
|
| 19 |
return """
|