Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #69 - Create migration scripts for DB [WIP] #130

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions ochazuke/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,16 +38,26 @@ 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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spaces on the 7 lines above seems to be not logical now.

What about?

   # 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')

or was it the result of black?

then maybe.

    from ochazuke.web import web_blueprint
    from ochazuke.api import api_blueprint

   # Web views for humans
    app.register_blueprint(web_blueprint)

    # Views for API clients
    app.register_blueprint(api_blueprint, url_prefix='/data')

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is weird. I hadn't noticed, but I think that is indeed some strange Black formatting, yes. I'll see what I can do to make it happy without the extra weirdness.



# Logging Capabilities
# To benefit from the logging, you may want to add:
# 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()
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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