Fix routes

This commit is contained in:
huchenlei 2024-06-19 21:21:50 -04:00
parent 97ae6ef460
commit 7c0f8934a5

View File

@ -538,8 +538,10 @@ class PromptServer():
# prefix are supported. # prefix are supported.
api_routes = web.RouteTableDef() api_routes = web.RouteTableDef()
for route in self.routes: for route in self.routes:
assert isinstance(route, web.RouteDef) # Custom nodes might add extra static routes. Only process non-static
api_routes.route(route.method, "/api" + route.path)(route.handler, **route.kwargs) # routes to add /api prefix.
if isinstance(route, web.RouteDef):
api_routes.route(route.method, "/api" + route.path)(route.handler, **route.kwargs)
self.app.add_routes(api_routes) self.app.add_routes(api_routes)
self.app.add_routes(self.routes) self.app.add_routes(self.routes)