Skip to content

Instantly share code, notes, and snippets.

@jacek-jablonski
Created February 9, 2018 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacek-jablonski/1e71a762119c34b2c0466252aede19be to your computer and use it in GitHub Desktop.
Save jacek-jablonski/1e71a762119c34b2c0466252aede19be to your computer and use it in GitHub Desktop.
# 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