mongkok / fastapi-debug-toolbar

A debug toolbar for FastAPI.
https://fastapi-debug-toolbar.domake.io
BSD 3-Clause "New" or "Revised" License
140 stars 14 forks source link

try version 1.1, 1.2, 1.3 but never see the toolbar #6

Closed ericfran closed 3 years ago

ericfran commented 3 years ago

Hi, I try it in a very simple Fastapi apps alike: from debug_toolbar.middleware import DebugToolbarMiddleware from fastapi import FastAPI

app = FastAPI(debug=True) app.add_middleware(DebugToolbarMiddleware)

@app.get("/") async def root(): return {"message": "Hello World"}

start with :uvicorn main :app

and doesn't works , I don't see the toolbar

logs: INFO: Application startup complete. INFO: 127.0.0.1:61005 - "GET / HTTP/1.1" 200 OK INFO: 127.0.0.1:61005 - "GET /docs HTTP/1.1" 200 OK INFO: 127.0.0.1:61005 - "GET /_debug_toolbar/static/css/toolbar.css HTTP/1.1" 304 Not Modified INFO: 127.0.0.1:50609 - "GET /_debug_toolbar/static/js/toolbar.js HTTP/1.1" 304 Not Modified INFO: 127.0.0.1:61063 - "GET /_debug_toolbar/static/js/refresh.js HTTP/1.1" 304 Not Modified INFO: 127.0.0.1:60063 - "GET /_debug_toolbar/static/img/icon-white.svg HTTP/1.1" 304 Not Modified INFO: 127.0.0.1:61063 - "GET /_debug_toolbar/static/css/print.css HTTP/1.1" 304 Not Modified INFO: 127.0.0.1:60063 - "GET /openapi.json HTTP/1.1" 200 OK

mongkok commented 3 years ago

Hey @ericfran , You can see a tab on the right side of any HTML page (e.g. Swagger UI /docs), please click it to open the toolbar. The tab can also be dragged up or down to place it wherever you like.

Debug Toolbar

ericfran commented 3 years ago

Hi, Ok thanks will check in coming days.

But I didn’t saw it …. 😔

Regards Eric

On 7 Aug 2021, at 16:48, Dani @.***> wrote:

 Hey @ericfran , You can see a tab on the right side of any HTML page (e.g. Swagger UI /docs), please click it to open the toolbar. The tab can also be dragged up or down to place it wherever you like.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

mongkok commented 3 years ago

if you can't see it.. let me know :)

josdavidmo commented 1 year ago

Hi! I have the same issue!

INFO: 172.18.0.1:36844 - "GET /css/toolbar.css HTTP/1.1" 304 Not Modified INFO: 172.18.0.1:36814 - "GET /img/icon-white.svg HTTP/1.1" 304 Not Modified INFO: 172.18.0.1:36828 - "GET /js/toolbar.js HTTP/1.1" 304 Not Modified

Could you please help me?

This is my requirements.txt file

alembic==1.11.3 bcrypt==4.0.1 boto3==1.28.35 cryptography==41.0.3 email-validator==2.0.0.post2 fastapi==0.103.0 mangum==0.17.0 passlib==1.7.4 pydantic_settings==2.0.3 PyMySQL==1.1.0 pytz==2023.3 python-dateutil==2.8.2 SQLAlchemy==2.0.20 sentry-sdk[fastapi]==1.29.2 pynamodb==5.5.0 dynamodb-json==1.3 python-jose[cryptography]==3.3.0 requests==2.31.0

Also, I'm using Docker to running the app with uvicorn

main:app --reload --host 0.0.0.0 --port 8000

josdavidmo commented 1 year ago

I discovered some things:

I need to define the api_url y staticurl to make the resources work, because uvicorn not work with or create de 304.

app.add_middleware(
    DebugToolbarMiddleware,
    api_url=f"/{settings.PROJECT_NAME}/debug",
    static_url=f"/{settings.PROJECT_NAME}/debug/static",
    ...
)

But the problem is that app not load the docs URI... I think that is a uvicorn problem