Example #1
0
def run():
    app = create_app()
    server_name = app.config.get('SERVER_NAME')
    if server_name is not None:
        # Assume local configuration with port given
        host, port = server_name.split(':')
        port = int(port)
    else:
        # Assume heroku configuration, no SERVER_NAME present, get port
        # from environment
        host = '0.0.0.0'
        port = int(os.environ.get('PORT', 5000))
    app.run(host=host, port=port)
Example #2
0
    create=(create, 'create tables'),
    reset=(reset, 'drop and create'),
)


def help(action=None):
    if action is not None:
        print 'Unknown command {0}'.format(str(action))
    print 'Please, use:'
    for name, (action, desc) in actions.items():
        print '{0} - {1}'.format(name, desc)


def _handle_cli():
    if len(sys.argv) < 2:
        help()
        sys.exit()
    action = sys.argv[1]
    if action not in actions:
        help(action)
        sys.exit()
    try:
        actions[action][0]()
    except Exception, e:
        print 'Error: ', e

if __name__ == '__main__':
    app = create_app()
    with app.test_request_context():
        _handle_cli()
Example #3
0
 def wrapped(*args, **kwargs):
     app = create_app(*create_app_args, **create_app_kwargs)
     with app.test_request_context():
         return f(*args, **kwargs)
Example #4
0
def create_app(subdomain=''):
    from discviz import create_app
    return create_app(subdomain)