From f901b223ef250a797eaecc688c9332d67d58de42 Mon Sep 17 00:00:00 2001 From: lanqian528 <5499636+lanqian528@users.noreply.github.com> Date: Sun, 27 Oct 2024 08:25:52 +0800 Subject: [PATCH] v1.5.8 use ua --- chat2api.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/chat2api.py b/chat2api.py index 1c60065..8147006 100644 --- a/chat2api.py +++ b/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: