mirror of
https://github.com/fastapi-admin/fastapi-admin.git
synced 2025-08-06 18:49:47 +08:00
fix: example
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import os
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
import redis.asyncio as redis
|
||||
import uvicorn
|
||||
@ -46,6 +47,7 @@ async def lifespan(app: FastAPI):
|
||||
],
|
||||
redis=r,
|
||||
)
|
||||
yield
|
||||
|
||||
|
||||
def create_app():
|
||||
@ -60,9 +62,7 @@ def create_app():
|
||||
async def index():
|
||||
return RedirectResponse(url="/admin")
|
||||
|
||||
admin_app.add_exception_handler(
|
||||
HTTP_500_INTERNAL_SERVER_ERROR, server_error_exception
|
||||
)
|
||||
admin_app.add_exception_handler(HTTP_500_INTERNAL_SERVER_ERROR, server_error_exception)
|
||||
admin_app.add_exception_handler(HTTP_404_NOT_FOUND, not_found_error_exception)
|
||||
admin_app.add_exception_handler(HTTP_403_FORBIDDEN, forbidden_error_exception)
|
||||
admin_app.add_exception_handler(HTTP_401_UNAUTHORIZED, unauthorized_error_exception)
|
||||
|
@ -119,7 +119,7 @@ class UsernamePasswordProvider(Provider):
|
||||
request: Request,
|
||||
call_next: RequestResponseEndpoint,
|
||||
):
|
||||
redis = request.app.redis # type:Redis
|
||||
redis = request.app.redis # type:ignore
|
||||
token = request.cookies.get(self.access_token)
|
||||
path = request.scope["path"]
|
||||
admin = None
|
||||
|
Reference in New Issue
Block a user