|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
-
-
-
-
-
-
-
-
-
- from flask import Flask
- from flask_sqlalchemy import SQLAlchemy
- from flask_login import LoginManager
- from flask_moment import Moment
- from flask_marshmallow import Marshmallow
- import os
-
-
- db = SQLAlchemy()
-
-
- ma = Marshmallow()
-
-
- moment = Moment()
-
- def create_app():
- app = Flask(__name__)
-
-
- app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY')
- app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL')
- app.config['SQLALCHEMY_ECHO'] = False
- app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
-
-
- app.config ['JSON_SORT_KEYS'] = False
-
- app.url_map.strict_slashes = False
-
- db.init_app(app)
-
- from . import models
-
- with app.app_context():
- db.create_all()
-
- login_manager = LoginManager()
- login_manager.login_view = 'auth.login'
- login_manager.init_app(app)
-
- moment.init_app(app)
-
- from .models import User
-
- @login_manager.user_loader
- def load_user(user_id):
-
- return User.query.get(int(user_id))
-
-
- from .auth import auth as auth_blueprint
- app.register_blueprint(auth_blueprint)
-
-
- from .main import main as main_blueprint
- app.register_blueprint(main_blueprint)
-
-
- from .tool import tool as tool_blueprint
- app.register_blueprint(tool_blueprint)
-
-
- from .practice import practice as practice_blueprint
- app.register_blueprint(practice_blueprint)
-
-
- from .book import book as book_blueprint
- app.register_blueprint(book_blueprint)
-
-
- from .create import create as create_blueprint
- app.register_blueprint(create_blueprint)
-
-
- from .api import api as api_blueprint
- app.register_blueprint(api_blueprint)
-
-
- from .search import search as search_blueprint
- app.register_blueprint(search_blueprint)
-
- return app
|