#7 Basic flask app. Setup routes, DB, and made a user model. Made initial migrations
This commit is contained in:
33
backend/app/__init__.py
Normal file
33
backend/app/__init__.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from flask import Flask
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_migrate import Migrate
|
||||
from flask_login import LoginManager
|
||||
from config import Config
|
||||
|
||||
|
||||
db = SQLAlchemy()
|
||||
migrate = Migrate()
|
||||
login = LoginManager()
|
||||
login.login_view = "login"
|
||||
login.login_message = "Please log in to access this page."
|
||||
|
||||
|
||||
def create_app(config_class=Config):
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(config_class)
|
||||
|
||||
db.init_app(app)
|
||||
migrate.init_app(app, db)
|
||||
login.init_app(app)
|
||||
|
||||
app.app_context().push()
|
||||
|
||||
from app.bp import bp as main_bp
|
||||
|
||||
app.register_blueprint(main_bp)
|
||||
|
||||
app.app_context()
|
||||
return app
|
||||
|
||||
|
||||
from app import models
|
||||
Reference in New Issue
Block a user