From dfe58215ae26f43dcb4c72302fa9c9850d185be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Thu, 27 Apr 2023 22:49:47 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20WebServer=20configuration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Karako --- .env.example | 7 +++---- core/config.py | 6 +++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index e6d812e9..01dd8143 100644 --- a/.env.example +++ b/.env.example @@ -84,10 +84,9 @@ LOGGER_FILTERED_NAMES=["uvicorn","ErrorPush","ApiHelper"] # ENKA_NETWORK_API_AGENT="" # Web Server -# WEB_SWITCH=False # 是否开启 -# WEB_URL=http://localhost:8080/ -# WEB_HOST=localhost -# WEB_PORT=8080 +# WEB_ENABLE=False # 是否开启 WebServer +# WEB_HOST=localhost # WebServer 监听地址 +# WEB_PORT=8080 # WebServer 监听端口 # error # ERROR_PB_URL=https://fars.ee diff --git a/core/config.py b/core/config.py index 78cc902f..fab896e4 100644 --- a/core/config.py +++ b/core/config.py @@ -68,13 +68,17 @@ class WebServerConfig(Settings): enable: bool = False """是否启用WebServer""" - url: AnyUrl = "http://localhost:8080" host: str = "localhost" port: int = 8080 class Config(Settings.Config): env_prefix = "web_" + @property + def url(self) -> str: + # noinspection HttpUrlsUsage + return "http://" + self.host + ":" + str(self.port) + class ErrorConfig(Settings): pb_url: str = ""