🚀 feat(main.py): add create_db_and_tables function to be called on app startup

The create_db_and_tables function is now called on app startup using the FastAPI on_event decorator. This ensures that the database and tables are created before the app starts listening for requests.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-09 12:37:39 -03:00
commit 73014b63f2

View file

@ -2,6 +2,7 @@ from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from langflow.api import router
from langflow.database.base import create_db_and_tables
def create_app():
@ -25,6 +26,7 @@ def create_app():
)
app.include_router(router)
app.on_event("startup")(create_db_and_tables)
return app