update-redis

merge-requests/4/head
王宇洋 3 years ago
parent 1c1dde102d
commit 83a1c27c76

@ -1 +1,3 @@
FLASK_APP=flasky.py
#FLASK_CONFIG=development
FLASK_CONFIG=production

@ -34,6 +34,9 @@ def create_app(config_name):
app.config.from_object(config[config_name])
config[config_name].init_app(app)
if config[config_name].DEBUG:
admin.init_app(app)
debug_toolbar.init_app(app)
bootstrap.init_app(app)
mail.init_app(app)
@ -43,9 +46,8 @@ def create_app(config_name):
db.init_app(app)
login_manager.init_app(app)
pagedown.init_app(app)
debug_toolbar.init_app(app)
flask_static_digest.init_app(app)
admin.init_app(app)
from .main import main as main_blueprint

@ -36,19 +36,23 @@ class Config:
class DevelopmentConfig(Config):
DEBUG = True
TESTING = True
SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URL') or \
'sqlite:///' + os.path.join(basedir, 'data-dev.sqlite')
class TestingConfig(Config):
DEBUG = False
TESTING = True
SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URL') or \
'sqlite://'
class ProductionConfig(Config):
DEBUG = False
TESTING = False
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
'sqlite:///' + os.path.join(basedir, 'data.sqlite')
'sqlite:///' + os.path.join(basedir, 'data-dev.sqlite')
config = {

Binary file not shown.

@ -14,8 +14,10 @@ from app.models import User, Role, Students, Permission, Post, Comment, Like, No
# if you want to execute the program
# please run this file
from config import config
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
config_name = os.getenv('FLASK_CONFIG') or 'default'
app = create_app(config_name)
migrate = Migrate(app, db, render_as_batch=True)
@ -94,6 +96,7 @@ def favicon():
# app.secret_key = GeetestLib.VERSION
# User, Role, Students, Permission, Post, Comment, Like, Notification, Transaction, Activity
if config[config_name].DEBUG:
admin.add_view(ModelView(User, db.session, name="Users", endpoint="users"))
admin.add_view(ModelView(Role, db.session, name="roles", endpoint="roles"))
admin.add_view(ModelView(Students, db.session, name="Studentss", endpoint="Studentss"))

Loading…
Cancel
Save