langflow/src/backend/langflow/main.py
Gabriel Luiz Freitas Almeida 3342e03a2c 🔀 refactor(langflow): move routers to a single file and add health check endpoint
The routers for the langflow API have been moved to a single file for better organization and maintainability. The routers have been imported and included in the main.py file using the new file. A new health check endpoint has been added to the API to check the status of the application.
2023-06-06 09:59:37 -03:00

37 lines
667 B
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from langflow.api import router
def create_app():
"""Create the FastAPI app and include the router."""
app = FastAPI()
origins = [
"*",
]
@app.get("/health")
def get_health():
return {"status": "OK"}
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(router)
return app
app = create_app()
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="127.0.0.1", port=7860)