Files
DjangoAdmin_FastAPI_EleVue/config/app.py
T
ClaudeandClaude dbcce79536 chore: 基线提交(重构前快照)
重构前保存现有 apps/ 结构基线,供后续各阶段回滚。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-07 09:43:18 +08:00

50 lines
2.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import logging
import os
_logger = logging.getLogger(__name__)
# 应用名称
FASTAPI_NAME = os.getenv('FASTAPI_NAME', 'FastAPI+EleVue旗舰版')
# 应用版本
FASTAPI_VERSION = os.getenv('FASTAPI_VERSION', 'v2.8.0')
# 应用运行地址
FASTAPI_HOST = os.getenv('FASTAPI_HOST', '127.0.0.1')
# 应用运行端口
FASTAPI_PORT = os.getenv('FASTAPI_PORT', 8031)
# 应用启动文件
FASTAPI_APP = os.getenv('FASTAPI_APP', 'main.py')
# 应用环境变量
FASTAPI_ENV = os.getenv('FASTAPI_ENV', 'development')
# 是否调试模式
FASTAPI_DEBUG = (os.getenv('FASTAPI_DEBUG', 'False') == 'True')
# 是否演示模式
FASTAPI_DEMO = (os.getenv('FASTAPI_DEMO', 'False') == 'True')
# 应用根目录
FASTAPI_ROOT_PATH = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
# 应用模板路径
FASTAPI_TEMPLATE_FOLDER = os.path.join(FASTAPI_ROOT_PATH, 'templates')
# 应用静态资源路径
FASTAPI_STATIC_FOLDER = os.path.join(FASTAPI_ROOT_PATH, 'static')
# 应用文件存储路径
FASTAPI_UPLOAD_DIR = os.getenv('FASTAPI_UPLOAD_DIR', os.path.join(FASTAPI_ROOT_PATH, 'uploads'))
# 正式图片路径
FASTAPI_IMAGE_PATH = os.path.join(FASTAPI_UPLOAD_DIR, 'images')
# 临时文件路径
FASTAPI_TEMP_PATH = os.path.join(FASTAPI_UPLOAD_DIR, 'temp')
# 应用图片域名
FASTAPI_IMAGE_URL = os.getenv('FASTAPI_IMAGE_URL', '')
# CORS允许的源(逗号分隔),未配置则允许所有源但不携带凭证
CORS_ALLOWED_ORIGINS = os.getenv('CORS_ALLOWED_ORIGINS', '')
# 可信代理层数(0=不信任X-Forwarded-For,1=一层反向代理,2=两层…)
# 仅当应用部署在Nginx等反向代理后才应设置为>=1
TRUSTED_PROXY_COUNT = int(os.getenv('TRUSTED_PROXY_COUNT', '0'))
# 允许上传的文件扩展名(逗号分隔,带点号)
UPLOAD_ALLOWED_EXTS = os.getenv('UPLOAD_ALLOWED_EXTS', '.jpg,.jpeg,.png,.gif,.bmp,.webp,.svg,.ico,.txt,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.mp3,.mp4,.zip,.rar,.7z')
# 上传文件大小上限(MB)
UPLOAD_MAX_SIZE_MB = int(os.getenv('UPLOAD_MAX_SIZE_MB', '10'))