-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathapp_config.py
More file actions
40 lines (30 loc) · 1.02 KB
/
app_config.py
File metadata and controls
40 lines (30 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
from dotenv import load_dotenv
# 加载环境变量
load_dotenv()
class Config:
"""应用配置类"""
# 后端配置
FLASK_ENV = os.getenv('FLASK_ENV', 'development')
FLASK_DEBUG = os.getenv('FLASK_DEBUG', 'True').lower() == 'true'
BACKEND_HOST = os.getenv('BACKEND_HOST', 'localhost')
BACKEND_PORT = int(os.getenv('BACKEND_PORT', 5050))
# 前端配置
FRONTEND_HOST = os.getenv('FRONTEND_HOST', 'localhost')
FRONTEND_PORT = int(os.getenv('FRONTEND_PORT', 3000))
# API配置
API_PREFIX = os.getenv('API_PREFIX', '/api')
# CORS配置
CORS_ORIGINS = "*"
# 其他配置
LOG_LEVEL = os.getenv('LOG_LEVEL', 'DEBUG')
@property
def backend_url(self):
"""获取后端完整URL"""
return f"http://{self.BACKEND_HOST}:{self.BACKEND_PORT}"
@property
def frontend_url(self):
"""获取前端完整URL"""
return f"http://{self.FRONTEND_HOST}:{self.FRONTEND_PORT}"
# 全局配置实例
config = Config()