From 706f6f5776ee3592db00df38f9bfe417a303869c Mon Sep 17 00:00:00 2001 From: wangwei Date: Mon, 14 Oct 2024 14:12:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 12 ++++++++++++ run.py | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 config.py create mode 100644 run.py diff --git a/config.py b/config.py new file mode 100644 index 0000000..13000a6 --- /dev/null +++ b/config.py @@ -0,0 +1,12 @@ +import os +from datetime import timedelta + +class Config: + SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess' + SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:Asdf123!@localhost/system' + SQLALCHEMY_TRACK_MODIFICATIONS = False + + # JWT 配置 + JWT_SECRET_KEY = 'your-secret-key' # 在生产环境中使用更安全的密钥 + JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=1) + JWT_REFRESH_TOKEN_EXPIRES = timedelta(days=30) diff --git a/run.py b/run.py new file mode 100644 index 0000000..eaa5527 --- /dev/null +++ b/run.py @@ -0,0 +1,19 @@ +from app import create_app, db +from app.models import User, Role, Permission, Department, RoleField # 添加所有你的模型 +import logging + +app = create_app() + +if __name__ == '__main__': + # 设置控制台日志 + console_handler = logging.StreamHandler() + console_handler.setLevel(logging.INFO) + formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') + console_handler.setFormatter(formatter) + app.logger.addHandler(console_handler) + + app.run(debug=True) + +@app.shell_context_processor +def make_shell_context(): + return {'db': db, 'User': User, 'Role': Role, 'Permission': Permission, 'Department': Department, 'RoleField': RoleField}