Update app/main.py
Browse files- app/main.py +9 -1
app/main.py
CHANGED
|
@@ -2,20 +2,28 @@ from fastapi import FastAPI
|
|
| 2 |
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
from app.routes import summarize
|
| 4 |
import os
|
|
|
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
os.environ['TRANSFORMERS_CACHE'] = '/tmp/hf_cache'
|
| 7 |
|
| 8 |
app = FastAPI()
|
| 9 |
|
|
|
|
| 10 |
app.add_middleware(
|
| 11 |
CORSMiddleware,
|
| 12 |
-
allow_origins=["*"],
|
| 13 |
allow_methods=["*"],
|
| 14 |
allow_headers=["*"],
|
| 15 |
)
|
| 16 |
|
| 17 |
@app.get("/")
|
| 18 |
def read_root():
|
|
|
|
| 19 |
return {"message": "AutoTLDR backend is running"}
|
| 20 |
|
|
|
|
| 21 |
app.include_router(summarize.router)
|
|
|
|
| 2 |
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
from app.routes import summarize
|
| 4 |
import os
|
| 5 |
+
import logging
|
| 6 |
|
| 7 |
+
# Configure basic logging
|
| 8 |
+
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
|
| 9 |
+
|
| 10 |
+
# Cache location (for Hugging Face Spaces)
|
| 11 |
os.environ['TRANSFORMERS_CACHE'] = '/tmp/hf_cache'
|
| 12 |
|
| 13 |
app = FastAPI()
|
| 14 |
|
| 15 |
+
# Enable CORS for all origins (safe here)
|
| 16 |
app.add_middleware(
|
| 17 |
CORSMiddleware,
|
| 18 |
+
allow_origins=["*"],
|
| 19 |
allow_methods=["*"],
|
| 20 |
allow_headers=["*"],
|
| 21 |
)
|
| 22 |
|
| 23 |
@app.get("/")
|
| 24 |
def read_root():
|
| 25 |
+
logging.info("Health check hit.")
|
| 26 |
return {"message": "AutoTLDR backend is running"}
|
| 27 |
|
| 28 |
+
# Mount routes
|
| 29 |
app.include_router(summarize.router)
|