@flaskbb.command('shell', short_help='Runs a shell in the app context.')
@with_appcontext
def shell_command():
 import code
 banner = ('Python %s on %s\nInstance Path: %s' % (sys.version, sys.platform, current_app.instance_path))
 ctx = {'db': db}
 startup = os.environ.get('PYTHONSTARTUP')
 if (startup and os.path.isfile(startup)):
  with open(startup, 'r') as f:
   eval(compile(f.read(), startup, 'exec'), ctx)
 ctx.update(current_app.make_shell_context())
 try:
  import IPython
  IPython.embed(banner1=banner, user_ns=ctx)
 except ImportError:
  code.interact(banner=banner, local=ctx)

@ flaskbb . command ( 'shell' , short_help = 'Runs a shell in the app context.' ) @ with_appcontext def shell_command ( ) : import code banner = ( 'Python %s on %s\nInstance Path: %s' % ( sys . version , sys . platform , current_app . instance_path ) ) ctx = { 'db' : db } startup = os . environ . get ( 'PYTHONSTARTUP' ) if ( startup and os . path . isfile ( startup ) ) : with open ( startup , 'r' ) as f : eval ( compile ( f . read ( ) , startup , 'exec' ) , ctx ) ctx . update ( current_app . make_shell_context ( ) ) try : import IPython IPython . embed ( banner1 = banner , user_ns = ctx ) except ImportError : code . interact ( banner = banner , local = ctx )
runs an interactive python shell in the context of a given flask application .