MinerU / app.py
SkyNait's picture
Add logging
7d41757 verified
raw
history blame
868 Bytes
#!/usr/bin/env python3
import os
import json
import uuid
import uvicorn
import pika
import logging
from fastapi import FastAPI, Body, Header, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from worker import main as rabbit_worker
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s - %(message)s"
)
logger = logging.getLogger(__name__)
app = FastAPI()
API_KEY = os.getenv("SECRET_KEY")
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
async def root():
logger.info("Root endpoint called.")
return {"status": "ok", "message": "API is running"}
if __name__ == "__main__":
os.system('python download_models_hf.py')
rabbit_worker()
uvicorn.run(app, host="0.0.0.0", port=8000)