Spaces:
Sleeping
Sleeping
# uvicorn app:app --host 0.0.0.0 --port 7860 --reload | |
from fastapi import FastAPI, HTTPException | |
from starlette.requests import Request | |
app = FastAPI() | |
def greet_json(): | |
return {"Hello": "World!"} | |
async def chat_completions(request:Request): | |
auth_header = request.headers['authorization'] | |
api_key = auth_header.split()[1] # 分割字符串并取第二个元素 | |
if api_key != "iam-tanbushi": | |
raise HTTPException(status_code=401, detail="Invalid API Key") | |
data = await request.json() | |
return {"data": data} |