mirror of
https://github.com/Jerryplusy/AI-powered-switches.git
synced 2025-10-14 01:39:18 +00:00
.
This commit is contained in:
parent
2af76f8a54
commit
8a4178a757
@ -1,24 +1,50 @@
|
||||
from pydantic_settings import BaseSettings
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
import sys
|
||||
|
||||
load_dotenv()
|
||||
ENV_FILE = ".env"
|
||||
|
||||
if not os.path.exists(ENV_FILE):
|
||||
default_env_content = """
|
||||
APP_NAME=AI Network Configurator
|
||||
DEBUG=True
|
||||
API_PREFIX=/api
|
||||
|
||||
SILICONFLOW_API_KEY=your-api-key-here
|
||||
SILICONFLOW_API_URL=https://api.siliconflow.cn/v1
|
||||
|
||||
SWITCH_USERNAME=admin
|
||||
SWITCH_PASSWORD=admin
|
||||
SWITCH_TIMEOUT=10
|
||||
|
||||
ENSP_DEFAULT_IP=172.17.99.201
|
||||
ENSP_DEFAULT_PORT=2000
|
||||
"""
|
||||
with open(ENV_FILE, "w", encoding="utf-8") as f:
|
||||
f.write(default_env_content)
|
||||
|
||||
print(f"已生成默认配置文件 {ENV_FILE} ,请修改后重新运行程序。")
|
||||
sys.exit(1)
|
||||
|
||||
# 加载 .env 文件
|
||||
load_dotenv(ENV_FILE)
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
APP_NAME: str = "AI Network Configurator"
|
||||
DEBUG: bool = True
|
||||
API_PREFIX: str = "/api"
|
||||
APP_NAME: str
|
||||
DEBUG: bool
|
||||
API_PREFIX: str
|
||||
|
||||
SILICONFLOW_API_KEY: str = os.getenv("SILICONFLOW_API_KEY", "sk-mhzuedasunrgdrxfkcxmxgaypgjnxgodvvmrzzdbqrwtkqej")
|
||||
SILICONFLOW_API_URL: str = os.getenv("SILICONFLOW_API_URL", "https://api.siliconflow.cn/v1")
|
||||
SILICONFLOW_API_KEY: str
|
||||
SILICONFLOW_API_URL: str
|
||||
|
||||
SWITCH_USERNAME: str = os.getenv("SWITCH_USERNAME", "admin")
|
||||
SWITCH_PASSWORD: str = os.getenv("SWITCH_PASSWORD", "admin")
|
||||
SWITCH_TIMEOUT: int = os.getenv("SWITCH_TIMEOUT", 10)
|
||||
SWITCH_USERNAME: str
|
||||
SWITCH_PASSWORD: str
|
||||
SWITCH_TIMEOUT: int
|
||||
|
||||
ENSP_DEFAULT_IP: str = "172.17.99.201"
|
||||
ENSP_DEFAULT_PORT: int = 2000
|
||||
ENSP_DEFAULT_IP: str
|
||||
ENSP_DEFAULT_PORT: int
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
|
Loading…
x
Reference in New Issue
Block a user