diff --git a/run.py b/run.py index b1a20ea..b893c22 100644 --- a/run.py +++ b/run.py @@ -4,7 +4,14 @@ import asyncio from server.database import db if __name__ == "__main__": asyncio.run(db.main()) - uvicorn.run("server.backend.endpoints:api", host="127.0.0.1", port=8000, reload=True) + uvicorn.run( + "server.backend.endpoints:api", + host="127.0.0.1", + port=8000, + reload=True, + log_level="info", + access_log=True + ) #ps aux | grep uvicorn # kill -9 pid \ No newline at end of file diff --git a/server/backend/endpoints.py b/server/backend/endpoints.py index c03764f..bc7703b 100644 --- a/server/backend/endpoints.py +++ b/server/backend/endpoints.py @@ -28,15 +28,15 @@ api.add_middleware( allow_headers=headers, ) -@api.middleware("http") #Логирование заходов перед всеми endpoints -async def log_requests(request: Request, call_next): - ip = request.client.host #ip - ua = request.headers.get("user-agent") #browser - method = request.method #method - url = str(request.url) #url - print(f"[{method}] {url} from {ip} ({ua})") - response = await call_next(request) - return response +# @api.middleware("http") #Логирование заходов перед всеми endpoints / возможно не нужен, так как то же самое делает uvicorn +# async def log_requests(request: Request, call_next): +# ip = request.client.host #ip +# ua = request.headers.get("user-agent") #browser +# method = request.method #method +# url = str(request.url) #url +# print(f"[{method}] {url} from {ip} ({ua})") +# response = await call_next(request) +# return response @api.get("/protected") #test async def protected(current_user: str = Depends(JWT.current_user)):