Created
February 9, 2018 18:18
-
-
Save jacek-jablonski/1e71a762119c34b2c0466252aede19be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file: app.py | |
from flask import Flask | |
from redis_instance import create_redis | |
def create_app(script_info: ScriptInfo = None): | |
app = Flask('myapp') | |
with app.app_context(): | |
from flask import g | |
g.redis = create_redis() | |
return app | |
# file: manage.py | |
from .app import create_app | |
from flask.cli import FlaskGroup | |
cli = FlaskGroup(create_app=create_app) | |
@cli.command(with_appcontext=True) | |
def fill_redis(): | |
from flask import g | |
redis = g.redis | |
.... oops |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment