import os import sys from datetime import timedelta # 获取 exe 的真实路径 exe_dir = os.path.dirname(sys.executable) if getattr(sys, 'frozen', False) else os.path.dirname(os.path.abspath(__file__)) class Config: SECRET_KEY = os.environ.get('SECRET_KEY') or 'your-secret-key-here' # 确保 instance 文件夹存在 instance_path = os.path.join(exe_dir, 'instance') if not os.path.exists(instance_path): os.makedirs(instance_path) SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \ 'sqlite:///' + os.path.join(instance_path, 'navigation.db') SQLALCHEMY_TRACK_MODIFICATIONS = False PERMANENT_SESSION_LIFETIME = timedelta(days=1)