mirror of
https://github.com/lanqian528/chat2api.git
synced 2026-06-13 21:02:46 +08:00
v1.5.8 use ua
This commit is contained in:
parent
e70a9410f8
commit
f901b223ef
12
chat2api.py
12
chat2api.py
@ -133,18 +133,22 @@ async def error_tokens():
|
||||
|
||||
if enable_gateway:
|
||||
@app.get("/", response_class=HTMLResponse)
|
||||
async def chatgpt(request: Request):
|
||||
async def chatgpt_html(request: Request):
|
||||
token = request.query_params.get("token")
|
||||
if not token:
|
||||
token = request.cookies.get("token")
|
||||
if not token:
|
||||
response = templates.TemplateResponse("login.html", {"request": request})
|
||||
return response
|
||||
return await login_html(request)
|
||||
|
||||
response = templates.TemplateResponse("chatgpt.html", {"request": request, "token": token})
|
||||
response.set_cookie("token", value=token)
|
||||
return response
|
||||
|
||||
@app.get("/login", response_class=HTMLResponse)
|
||||
async def login_html(request: Request):
|
||||
response = templates.TemplateResponse("login.html", {"request": request})
|
||||
return response
|
||||
|
||||
|
||||
@app.get("/backend-api/gizmos/bootstrap")
|
||||
async def get_gizmos_bootstrap():
|
||||
@ -214,7 +218,7 @@ if enable_gateway:
|
||||
async def reverse_proxy(request: Request, path: str):
|
||||
for chatgpt_path in chatgpt_paths:
|
||||
if chatgpt_path in path:
|
||||
return await chatgpt(request)
|
||||
return await chatgpt_html(request)
|
||||
|
||||
for banned_path in banned_paths:
|
||||
if banned_path in path:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user