[Question] Mount Piccolo Admin to Starlite app
See original GitHub issueHello, First I want to thanks all for this great new framework. I would like to implement a Starlite asgi template for Piccolo ORM. Piccolo ORM is an easy-to-use async orm with an integrated web admin. Piccolo ORM currently support Starlette, FastAPI, BlackSheep and Xpresso (all this frameworks support mounting asgi apps) and it would be nice if we could add Starlite support. I have already implemented a basic CRUD for Piccolo tables, but the main problem is mounting Piccolo Admin (which is already an asgi application) on the Starlite app.
Starlite routing has a different design and you can only run the another asgi application through middleware which work,
# some other import
from piccolo_admin.endpoints import create_admin
from starlite import Starlite
from home.piccolo_app import APP_CONFIG
# Piccolo Admin asgi app
admin_app = create_admin(tables=APP_CONFIG.table_classes)
class AdminMiddleware(MiddlewareProtocol):
def __init__(self, app: ASGIApp):
self.app = admin_app
async def __call__(
self, scope: Scope, receive: Receive, send: Send
) -> None:
if scope["type"] == "http":
request = Request(scope)
await self.app(scope, receive, send)
app = Starlite(
middleware=[AdminMiddleware],
...
)
but that didn’t solve the main problem because admin app is mounted to root path and any other routes from route_handlers
is not accesible (e.g /tasks
). Router
class also does not work because route_handlers
accept standalone function or controller but not asgi app.
Is it possible to mount Piccolo Admin on the /admin
route (other frameworks have Mount
or app.mount
), and the rest of the Starlite app is on the root path?
Sorry for long comment (I hope I have explained the problem well) but any help appriciated.
Thanks.
Issue Analytics
- State:
- Created a year ago
- Comments:15 (8 by maintainers)
Sure thing. Note- for my money this is mounted, there is an error being returned from it, but the cause of the error cannot be ascertain without debugging the code internally. The issue is no longer with the mount - its something else. @sinisaos
I already added the admin function to
route_handlers
before and get an error.No problem. There doesn’t seem to be an easy way to mount Piccolo Admin, but it doesn’t matter, I just wanted to give it a try. Thanks for your time and help. I will close this issue. Cheers.