chainlit icon indicating copy to clipboard operation
chainlit copied to clipboard

Custom API endpoints not working anymore

Open Jimmy-Newtron opened this issue 1 year ago • 4 comments
trafficstars

          > This new way to handle resources access is breaking the custom endpoints that I add to the server

This is my solution to patch and temporarily fix the issue caused by the serve route

from chainlit.server import app
from starlette.routing import BaseRoute, Route

from src.core.routers import admin

routes: list[BaseRoute] = [
    r for r in app.router.routes if isinstance(r, Route) and r.name != "serve"
]

serve_route = [
    r for r in app.router.routes if isinstance(r, Route) and r.name == "serve"
]

app.router.routes = routes

app.include_router(admin.router)

app.router.routes.extend(serve_route)

Originally posted by @Jimmy-Newtron in https://github.com/Chainlit/chainlit/issues/1064#issuecomment-2186946521

Jimmy-Newtron avatar Jun 24 '24 16:06 Jimmy-Newtron