🚀 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:
parent
95588c7dc9
commit
73014b63f2
1 changed files with 2 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ from fastapi import FastAPI
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
from langflow.api import router
|
from langflow.api import router
|
||||||
|
from langflow.database.base import create_db_and_tables
|
||||||
|
|
||||||
|
|
||||||
def create_app():
|
def create_app():
|
||||||
|
|
@ -25,6 +26,7 @@ def create_app():
|
||||||
)
|
)
|
||||||
|
|
||||||
app.include_router(router)
|
app.include_router(router)
|
||||||
|
app.on_event("startup")(create_db_and_tables)
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue