Spaces:
Sleeping
Sleeping
api-key
Browse files
app.py
CHANGED
@@ -1,15 +1,7 @@
|
|
1 |
# uvicorn app:app --host 0.0.0.0 --port 7860 --reload
|
2 |
|
3 |
-
from fastapi import FastAPI,
|
4 |
from starlette.requests import Request
|
5 |
-
from pydantic import BaseModel, RootModel
|
6 |
-
import starlette
|
7 |
-
|
8 |
-
# 继承自 BaseModel 而不是直接继承 Request,因为 Request 本身不是一个 Pydantic 模型
|
9 |
-
class AirsRequest(Request):
|
10 |
-
# request: Request
|
11 |
-
# 添加额外的 api_key 属性
|
12 |
-
api_key: str
|
13 |
|
14 |
app = FastAPI()
|
15 |
|
@@ -24,5 +16,4 @@ async def chat_completions(request:Request):
|
|
24 |
if api_key != "iam-tanbushi":
|
25 |
raise HTTPException(status_code=401, detail="Invalid API Key")
|
26 |
data = await request.json()
|
27 |
-
# print('data',data)
|
28 |
return {"data": data}
|
|
|
1 |
# uvicorn app:app --host 0.0.0.0 --port 7860 --reload
|
2 |
|
3 |
+
from fastapi import FastAPI, HTTPException
|
4 |
from starlette.requests import Request
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
app = FastAPI()
|
7 |
|
|
|
16 |
if api_key != "iam-tanbushi":
|
17 |
raise HTTPException(status_code=401, detail="Invalid API Key")
|
18 |
data = await request.json()
|
|
|
19 |
return {"data": data}
|