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.
37 lines
667 B
Python
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)
|