mongkok / fastapi-debug-toolbar

A debug toolbar for FastAPI.

Home Page:https://fastapi-debug-toolbar.domake.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

ericfran opened this issue · comments

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

commented

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

commented

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

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

I discovered some things:

I need to define the api_url y static_url 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