fix: example

This commit is contained in:
long2ice
2024-05-22 18:14:59 +08:00
parent e4a4cd511b
commit 66b69c29fc
3 changed files with 48 additions and 48 deletions

View File

@ -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)

View File

@ -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