question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Mount Piccolo Admin to Starlite app

See original GitHub issue

Hello, 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:closed
  • Created a year ago
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Goldzihercommented, May 8, 2022

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

1reaction
sinisaoscommented, May 8, 2022

I already added the admin function to route_handlers before and get an error.

I am getting an internal server error after i created the user as per the documentation served from 127.0.0.1:8000, but i am running the DB in docker etc. and have no clue if im using this correctly. I did attach a debugger to this stuff, but I am not sure I want to really delve into this code to figure out why the fast api based admin is not working

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changes — Piccolo 0.102.0 documentation - Read the Docs
Updated the Starlite ASGI template, so it uses the latest syntax for mounting Piccolo Admin (thanks to @sinisaos for this, and the Starlite...
Read more >
piccolo-orm/piccolo_admin: A powerful web admin ... - GitHub
Works on mobile and desktop; Use standalone, or integrate it easily with ASGI apps like FastAPI, and Starlette; Multilingual out of box; Bulk...
Read more >
Starlite
Starlite is a powerful, flexible, highly performant and opinionated ASGI framework, offering first class typing support and a full Pydantic integration.
Read more >
VWF - River Thames Conditions
Water slide tester application, Nodar grigoriani, Estadios irc kdoqi, Dani bolina carnaval, Ranipuram national park, Forgot admin password macbook pro, ...
Read more >
Service Name and Transport Protocol Port Number Registry
FIREWALL AND SYSTEM ADMINISTRATORS SHOULD * * CHOOSE HOW TO CONFIGURE THEIR SYSTEMS BASED ON THEIR KNOWLEDGE OF * * THE TRAFFIC IN...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found