chore: add configurable HOST and PORT via .env file

支持通过.env配置服务器HOST和PORT
This commit is contained in:
alchemin
2025-11-06 15:24:24 +08:00
parent 950bf0d341
commit f1794d4da9
3 changed files with 17 additions and 3 deletions
+7 -2
View File
@@ -47,6 +47,8 @@ LOG_DIR.mkdir(exist_ok=True)
CONFIG_MODULE_NAME = 'config'
CONFIG_FILE_PATH = Path(__file__).resolve().parent / 'config.py'
CONFIG_KEYS = [
'HOST',
'PORT',
'DB_DIALECT',
'DB_HOST',
'DB_PORT',
@@ -1018,8 +1020,11 @@ def handle_status_request():
})
if __name__ == '__main__':
HOST = '0.0.0.0'
PORT = 5000
# 从配置文件读取 HOST 和 PORT
from config import settings
HOST = settings.HOST
PORT = settings.PORT
logger.info("等待配置确认,系统将在前端指令后启动组件...")
logger.info(f"Flask服务器已启动,访问地址: http://{HOST}:{PORT}")