Some past commits might have contained Cursor's IP or accidentally commited API keys. Before making the repository public, all the history has been squashed into a single commit with.
42 lines
1012 B
Python
42 lines
1012 B
Python
"""The app module, containing the app factory function."""
|
|
|
|
import logging
|
|
import sys
|
|
|
|
from flask import Flask
|
|
|
|
from . import commands
|
|
from .blueprint import blueprint
|
|
|
|
|
|
def create_app(config_object="app.settings"):
|
|
"""Create application factory, as explained here: http://flask.pocoo.org/docs/patterns/appfactories/.
|
|
|
|
:param config_object: The configuration object to use.
|
|
"""
|
|
app = Flask(__name__.split(".")[0])
|
|
app.config.from_object(config_object)
|
|
register_commands(app)
|
|
register_blueprints(app)
|
|
configure_logger(app)
|
|
return app
|
|
|
|
|
|
def register_blueprints(app):
|
|
"""Register Flask blueprints."""
|
|
app.register_blueprint(blueprint)
|
|
return None
|
|
|
|
|
|
def register_commands(app):
|
|
"""Register Click commands."""
|
|
app.cli.add_command(commands.test)
|
|
app.cli.add_command(commands.lint)
|
|
|
|
|
|
def configure_logger(app):
|
|
"""Configure loggers."""
|
|
handler = logging.StreamHandler(sys.stdout)
|
|
if not app.logger.handlers:
|
|
app.logger.addHandler(handler)
|