Revert "Make app object easily accessible from gunicorn"
This reverts commit 6e25af03c4
.
This commit is contained in:
parent
6e25af03c4
commit
33d10c20a1
|
@ -5,35 +5,37 @@ from os import environ
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from . import twitch
|
from . import twitch
|
||||||
|
|
||||||
# Setup logging
|
|
||||||
debug = environ.get("FLASK_ENV", "production") == "development"
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
level = logging.DEBUG if debug else logging.INFO
|
|
||||||
logging.basicConfig(level=level)
|
|
||||||
|
|
||||||
# Read configuration
|
|
||||||
config_path = environ.get("FEEDLEWARE_CONFIG")
|
|
||||||
|
|
||||||
if not config_path:
|
|
||||||
print(
|
|
||||||
"Please set the FEEDLEWARE_CONFIG environment variable",
|
|
||||||
file=sys.stderr,
|
|
||||||
)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
|
||||||
config.read(config_path)
|
|
||||||
|
|
||||||
# Instantiate app and attach blueprints
|
|
||||||
app = Flask(__name__)
|
|
||||||
|
|
||||||
blueprints = {
|
blueprints = {
|
||||||
"twitch": twitch,
|
"twitch": twitch,
|
||||||
}
|
}
|
||||||
|
|
||||||
for section in config.sections():
|
|
||||||
if section in blueprints:
|
def create_app():
|
||||||
blueprint = blueprints[section].create_blueprint(config[section])
|
"""Read the app configuration and instantiate service blueprints."""
|
||||||
app.register_blueprint(blueprint, url_prefix="/" + section)
|
debug = environ.get("FLASK_ENV", "production") == "development"
|
||||||
else:
|
level = logging.DEBUG if debug else logging.INFO
|
||||||
logger.warning("Unknown service '%s'", section)
|
logging.basicConfig(level=level)
|
||||||
|
|
||||||
|
config_path = environ.get("FEEDLEWARE_CONFIG")
|
||||||
|
|
||||||
|
if not config_path:
|
||||||
|
print(
|
||||||
|
"Please set the FEEDLEWARE_CONFIG environment variable",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read(config_path)
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
for section in config.sections():
|
||||||
|
if section in blueprints:
|
||||||
|
blueprint = blueprints[section].create_blueprint(config[section])
|
||||||
|
app.register_blueprint(blueprint, url_prefix="/" + section)
|
||||||
|
else:
|
||||||
|
logger.warning("Unknown service '%s'", section)
|
||||||
|
|
||||||
|
return app
|
||||||
|
|
Loading…
Reference in New Issue