diff --git a/ochazuke/__init__.py b/ochazuke/__init__.py index b80eba5..53d4ca9 100644 --- a/ochazuke/__init__.py +++ b/ochazuke/__init__.py @@ -10,21 +10,25 @@ from flask import Flask from flask_sqlalchemy import SQLAlchemy +from flask_migrate import Migrate from config import config db = SQLAlchemy() +migrate = Migrate() def create_app(config_name): """Create the main webcompat metrics server app.""" - # create and configure the app + # Create and configure the app app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) # DB init db.init_app(app) + # Migration setup + migrate.init_app(app, db) # Blueprint configure_blueprints(app) return app @@ -34,10 +38,12 @@ def configure_blueprints(app): """Define the blueprints for the project.""" # Web views for humans from ochazuke.web import web_blueprint + app.register_blueprint(web_blueprint) # Views for API clients from ochazuke.api import api_blueprint - app.register_blueprint(api_blueprint, url_prefix='/data') + + app.register_blueprint(api_blueprint, url_prefix="/data") # Logging Capabilities @@ -45,5 +51,13 @@ def configure_blueprints(app): # app.logger.info(Thing_To_Log) # it will create a line with the following format # (2015-09-14 20:50:19) INFO: Thing_To_Log -logging.basicConfig(format='(%(asctime)s) %(levelname)s: %(message)s', - datefmt='%Y-%m-%d %H:%M:%S %z', level=logging.INFO) +logging.basicConfig( + format="(%(asctime)s) %(levelname)s: %(message)s", + datefmt="%Y-%m-%d %H:%M:%S %z", + level=logging.INFO, +) + +application = create_app("development") + +if __name__ == "__main__": + application.run() diff --git a/requirements.txt b/requirements.txt index 534b8d0..64b3c4a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ flake8==3.7.7 nose2==0.9.1 psycopg2-binary==2.8.2 Flask-SQLAlchemy==2.4.0 +Flask-Migrate==2.5.2