def init_app(settings_module='website.settings', set_backends=True, routes=True, attach_request_handlers=True, fixtures=True):
 if (app.config.get('IS_INITIALIZED', False) is True):
  return app
 logger.info('Initializing the application from process {}, thread {}.'.format(os.getpid(), thread.get_ident()))
 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'api.base.settings')
 django.setup()
 settings = importlib.import_module(settings_module)
 init_addons(settings, routes)
 with open(os.path.join(settings.STATIC_FOLDER, 'built', 'nodeCategories.json'), 'wb') as fp:
  json.dump(settings.NODE_CATEGORY_MAP, fp)
 patch_models(settings)
 app.debug = settings.DEBUG_MODE
 app.config['SESSION_COOKIE_SECURE'] = settings.SESSION_COOKIE_SECURE
 app.config['SESSION_COOKIE_HTTPONLY'] = settings.SESSION_COOKIE_HTTPONLY
 if set_backends:
  do_set_backends(settings)
 if routes:
  try:
   from website.routes import make_url_map
   make_url_map(app)
  except AssertionError:
   pass
 if attach_request_handlers:
  attach_handlers(app, settings)
 if app.debug:
  logger.info("Sentry disabled; Flask's debug mode enabled")
 else:
  sentry.init_app(app)
  logger.info("Sentry enabled; Flask's debug mode disabled")
 if (set_backends and fixtures):
  ensure_schemas()
  ensure_licenses()
 apply_middlewares(app, settings)
 app.config['IS_INITIALIZED'] = True
 return app

def init_app ( settings_module = 'website.settings' , set_backends = True , routes = True , attach_request_handlers = True , fixtures = True ) : if ( app . config . get ( 'IS_INITIALIZED' , False ) is True ) : return app logger . info ( 'Initializing the application from process {}, thread {}.' . format ( os . getpid ( ) , thread . get_ident ( ) ) ) os . environ . setdefault ( 'DJANGO_SETTINGS_MODULE' , 'api.base.settings' ) django . setup ( ) settings = importlib . import_module ( settings_module ) init_addons ( settings , routes ) with open ( os . path . join ( settings . STATIC_FOLDER , 'built' , 'nodeCategories.json' ) , 'wb' ) as fp : json . dump ( settings . NODE_CATEGORY_MAP , fp ) patch_models ( settings ) app . debug = settings . DEBUG_MODE app . config [ 'SESSION_COOKIE_SECURE' ] = settings . SESSION_COOKIE_SECURE app . config [ 'SESSION_COOKIE_HTTPONLY' ] = settings . SESSION_COOKIE_HTTPONLY if set_backends : do_set_backends ( settings ) if routes : try : from website . routes import make_url_map make_url_map ( app ) except AssertionError : pass if attach_request_handlers : attach_handlers ( app , settings ) if app . debug : logger . info ( "Sentry disabled; Flask's debug mode enabled" ) else : sentry . init_app ( app ) logger . info ( "Sentry enabled; Flask's debug mode disabled" ) if ( set_backends and fixtures ) : ensure_schemas ( ) ensure_licenses ( ) apply_middlewares ( app , settings ) app . config [ 'IS_INITIALIZED' ] = True return app
inititalize an application prog is the full command with args output true if output should be returned false if output should be dumped to null .