You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- from flask import Flask
- from flask_sqlalchemy import SQLAlchemy
- from flask_login import LoginManager
- import os
-
- # init SQLAlchemy so we can use it later in our models
- db = SQLAlchemy()
-
- 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')
-
- db.init_app(app)
-
- login_manager = LoginManager()
- login_manager.login_view = 'auth.login'
- login_manager.init_app(app)
-
- from .models import User
-
- @login_manager.user_loader
- def load_user(user_id):
- # since the user_id is just the primary key of our user table, use it in the query for the user
- return User.query.get(int(user_id))
-
- # blueprint for auth routes in our app
- from .auth import auth as auth_blueprint
- app.register_blueprint(auth_blueprint)
-
- # blueprint for non-auth parts of app
- from .main import main as main_blueprint
- app.register_blueprint(main_blueprint)
-
- # blueprint for tools parts of app
- from .tool import tool as tool_blueprint
- app.register_blueprint(tool_blueprint)
-
- return app
|