From 3aee06caceba7b6ed66da467ab29cf7425427623 Mon Sep 17 00:00:00 2001 From: kicer Date: Sat, 24 Jan 2026 17:22:58 +0800 Subject: [PATCH] =?UTF-8?q?url=E4=B9=9F=E6=94=B9=E5=88=B0config=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=AD=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rom/app.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rom/app.py b/src/rom/app.py index ce6adbf..6e76bbc 100644 --- a/src/rom/app.py +++ b/src/rom/app.py @@ -59,7 +59,9 @@ def get_weather_data(city=None, force=False): if city is None: city = config.get("city", "北京") - url = f"https://iot.foresh.com/api/weather?city={city}" + # 从配置获取API基础URL,默认使用官方API + api_base = config.get("weather_api_url", "https://iot.foresh.com/api/weather") + url = f"{api_base}?city={city}" print(f"正在获取{city}天气数据...") # 发送GET请求 @@ -202,7 +204,7 @@ def start(): async def config_update(request): ack = {"status": "success"} try: - content_length = int(request.headers['Content-Length']) + content_length = int(request.headers["Content-Length"]) post_data = (await request.read(content_length)).decode() for k, v in json.loads(post_data).items():