Spaces:
Sleeping
Sleeping
update
Browse files- proxyserver-fastapi.py +5 -3
proxyserver-fastapi.py
CHANGED
|
@@ -2,7 +2,7 @@ from fastapi import FastAPI, Request, HTTPException
|
|
| 2 |
from fastapi.responses import StreamingResponse, Response
|
| 3 |
import httpx
|
| 4 |
import uvicorn
|
| 5 |
-
import asyncio, os
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
|
| 8 |
# 加载 .env 文件中的环境变量
|
|
@@ -87,11 +87,13 @@ async def proxy_request(url_path: str, request: Request):
|
|
| 87 |
# 将检索到的第三方API密钥添加到目标API的请求头中
|
| 88 |
headers["authorization"] = f"Bearer {third_party_api_key}"
|
| 89 |
print(f"添加第三方API Key到请求头: Authorization: Bearer {third_party_api_key[:5]}...")
|
| 90 |
-
print(
|
|
|
|
| 91 |
|
| 92 |
headers=[]
|
| 93 |
headers["authorization"]=f"Bearer {third_party_api_key}"
|
| 94 |
-
print(
|
|
|
|
| 95 |
|
| 96 |
|
| 97 |
|
|
|
|
| 2 |
from fastapi.responses import StreamingResponse, Response
|
| 3 |
import httpx
|
| 4 |
import uvicorn
|
| 5 |
+
import asyncio, os, json
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
|
| 8 |
# 加载 .env 文件中的环境变量
|
|
|
|
| 87 |
# 将检索到的第三方API密钥添加到目标API的请求头中
|
| 88 |
headers["authorization"] = f"Bearer {third_party_api_key}"
|
| 89 |
print(f"添加第三方API Key到请求头: Authorization: Bearer {third_party_api_key[:5]}...")
|
| 90 |
+
print("\n\n请求头部-1: ")
|
| 91 |
+
json.dumps(headers, indent=4, sort_keys=True, ensure_ascii=False)
|
| 92 |
|
| 93 |
headers=[]
|
| 94 |
headers["authorization"]=f"Bearer {third_party_api_key}"
|
| 95 |
+
print("\n\n请求头部-2: ")
|
| 96 |
+
json.dumps(headers, indent=4, sort_keys=True, ensure_ascii=False)
|
| 97 |
|
| 98 |
|
| 99 |
|