Corvius commited on
Commit
e05e282
·
verified ·
1 Parent(s): e382c3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -1,11 +1,6 @@
1
  from fastapi import FastAPI, Request
2
- from fastapi.responses import JSONResponse
3
  import uvicorn
4
- import logging
5
- import json
6
-
7
- logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
8
- logger = logging.getLogger(__name__)
9
 
10
  app = FastAPI()
11
 
@@ -14,11 +9,11 @@ async def proxy(request: Request, full_path: str):
14
  auth_header = request.headers.get("authorization")
15
 
16
  if auth_header:
17
- log_message = f"Intercepted authorization header: {auth_header}"
18
- logger.info(log_message)
19
- return JSONResponse(content={"message": "Authorization logged", "authorization": auth_header})
20
  else:
21
- return JSONResponse(content={"message": "No authorization header found"})
22
 
23
  if __name__ == "__main__":
24
  uvicorn.run(app, host="0.0.0.0", port=7860)
 
1
  from fastapi import FastAPI, Request
2
+ from fastapi.responses import PlainTextResponse
3
  import uvicorn
 
 
 
 
 
4
 
5
  app = FastAPI()
6
 
 
9
  auth_header = request.headers.get("authorization")
10
 
11
  if auth_header:
12
+ output = f'"authorization": {auth_header}'
13
+ print(output) # This will appear in the logs
14
+ return PlainTextResponse(output)
15
  else:
16
+ return PlainTextResponse("No authorization header found")
17
 
18
  if __name__ == "__main__":
19
  uvicorn.run(app, host="0.0.0.0", port=7860)