This commit is contained in:
ddrwode
2026-02-09 14:18:42 +08:00
commit 3a61598b59
51 changed files with 5674 additions and 0 deletions

35
config.py Normal file
View File

@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
"""应用配置"""
import os
from urllib.parse import quote_plus
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
# MySQL 连接(可通过环境变量覆盖)
DB_HOST = os.environ.get("DB_HOST") or "199.168.137.123"
DB_PORT = os.environ.get("DB_PORT") or "3309"
DB_USER = os.environ.get("DB_USER") or "vps"
DB_NAME = os.environ.get("DB_NAME") or "vps"
DB_PASSWORD = os.environ.get("DB_PASSWORD") or "435Y4fPrZxT86wNx"
def _mysql_uri():
password = quote_plus(DB_PASSWORD)
return f"mysql+pymysql://{DB_USER}:{password}@{DB_HOST}:{DB_PORT}/{DB_NAME}?charset=utf8mb4"
class Config:
SECRET_KEY = os.environ.get("SECRET_KEY") or "dev-secret-change-in-production"
ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD") or "admin123"
# 优先使用 DATABASE_URL否则使用 MySQL
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL") or _mysql_uri()
SQLALCHEMY_TRACK_MODIFICATIONS = False
SITE_URL = os.environ.get("SITE_URL") or "https://example.com"
SITE_NAME = "云服务器价格对比"
# 兼容直接 from config import XXX
SECRET_KEY = Config.SECRET_KEY
ADMIN_PASSWORD = Config.ADMIN_PASSWORD
SITE_URL = Config.SITE_URL
SITE_NAME = Config.SITE_NAME