2 Star 3 Fork 3

vencen/FlaskApi-Template

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
config.py 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
shangfr 提交于 2021-07-13 15:40 . init
import os
from datetime import timedelta
basedir = os.path.abspath(os.path.dirname(__file__))
class Config:
# Change the secret key in production run.
SECRET_KEY = os.environ.get("SECRET_KEY", os.urandom(24))
DEBUG = False
#DRIVER = 'pymysql'
# JWT Extended config
JWT_SECRET_KEY = os.environ.get("JWT_SECRET_KEY", os.urandom(24))
## Set the token to expire every week
JWT_ACCESS_TOKEN_EXPIRES = timedelta(days=7)
# 异常处理
PROPAGATE_EXCEPTIONS = True
class DevelopmentConfig(Config):
DEBUG = True
SQLALCHEMY_DATABASE_URI = os.environ.get(
"DATABASE_URL", "sqlite:///" + os.path.join(basedir, "data-dev.sqlite")
)
SQLALCHEMY_TRACK_MODIFICATIONS = False
# Add logger
class TestingConfig(Config):
DEBUG = True
TESTING = True
# In-memory SQLite for testing
SQLALCHEMY_DATABASE_URI = "sqlite:///:memory:"
PRESERVE_CONTEXT_ON_EXCEPTION = False
SQLALCHEMY_TRACK_MODIFICATIONS = False
class ProductionConfig(Config):
DEBUG = False
SQLALCHEMY_DATABASE_URI = os.environ.get(
"DATABASE_URL", "sqlite:///" + os.path.join(basedir, "data.sqlite")
)
SQLALCHEMY_TRACK_MODIFICATIONS = False
config_by_name = dict(
development=DevelopmentConfig,
testing=TestingConfig,
production=ProductionConfig,
default=DevelopmentConfig,
)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/vencen/FlaskApi-Template.git
git@gitee.com:vencen/FlaskApi-Template.git
vencen
FlaskApi-Template
FlaskApi-Template
master

搜索帮助