From 104e92350b865c7220b239f18ad487afb94e5d24 Mon Sep 17 00:00:00 2001 From: GamerNoTitle Date: Thu, 31 Oct 2024 23:09:25 +0800 Subject: [PATCH] fix: give template default value --- app/main.py | 11 ++++++++++- app/templates/index.html | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index e782d0a..903b2c1 100644 --- a/app/main.py +++ b/app/main.py @@ -53,7 +53,16 @@ def get_xml_data(server: str, ticket_path: str): @app.get("/", response_class=HTMLResponse) async def index(request: Request): - return templates.TemplateResponse("index.html", {"request": request}) + # 提供默认的 release_data 和 obtain_data + return templates.TemplateResponse( + "index.html", + { + "request": request, + "release_data": None, # 默认值 + "obtain_data": None, # 默认值 + "server": None, # 默认服务器地址为空 + }, + ) @app.post("/fetch", response_class=HTMLResponse) diff --git a/app/templates/index.html b/app/templates/index.html index fcd2837..52dc8e3 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -16,7 +16,7 @@
- {% if obtain_data.response_code == "" %} + {% if obtain_data.response_code | default ("") == "" %}

Please input your server to check.

{% elif obtain_data.error %}

{{ obtain_data.error }}