Exemplo n.º 1
0
def standard_ping():
    """ Runs ping on the provided url

    Returns: HTTPResponse 200 with a json containing the ping info.
    BadRequest 400 if no uri is specified or the uri is malformed/cannot be pingd.
    """
    try:
        uri = request.args['uri'].replace('https://', '').replace('http://', '')
    except KeyError:
        raise BadRequest("Host query parameter is missing from your request.")

    return ping([uri],
                app.config['PING21_ALLOW_PRIVATE'],
                app.config['PING21_DEFAULT_ECHO'],
                app.config['PING21_MAX_ECHO'])
Exemplo n.º 2
0
def cli_ping():
    return ping(request.get_json()['args'],
                app.config['PING21_ALLOW_PRIVATE'],
                app.config['PING21_DEFAULT_ECHO'],
                app.config['PING21_MAX_ECHO'])