Triventure-AI / app.py
ABAO77's picture
Upload 37 files
5ce8318 verified
raw
history blame contribute delete
667 Bytes
from dotenv import load_dotenv
load_dotenv(override=True)
from src.apis.create_app import create_app, api_router
import uvicorn
from src.apis.storage.database import db
from src.utils.model_downloader import download_model_if_not_exists
app = create_app()
app.include_router(api_router)
@app.on_event("startup")
def startup_event():
"""
Connect to the database and download model if needed when the API starts.
"""
db.connect()
@app.on_event("shutdown")
def shutdown_event():
"""
Close the database connection when the API shuts down.
"""
db.close()
if __name__ == "__main__":
uvicorn.run("app:app", host="0.0.0.0", port=7880)