Esempio n. 1
0
def whois(query):
    accept = request.headers['Accept'].split(',')
    data = query_whois(query)
    data = data.replace('\uFFFD', '?') # replace UTF-8's 'REPLACEMENT CHARCTER' with '?'
    if 'text/html' in accept:
        return render_template('whois_response.html', data=data, title='WHOIS Result')
    return Response(data, mimetype='text/plain')
Esempio n. 2
0
def plaintext_whois(query):
    res = query_whois(query)
    lines = res.split('\n')
    for line in lines:
        match = COMMENTS_REGEX.match(line)
        if match:
            lines.remove(line)
    res = '\n'.join(lines)
    return Response(res, mimetype='text/plain')
Esempio n. 3
0
def api_v1_query_whois():
    query = request.json['query']
    res = {
        'raw': query_whois(query)
    }
    return jsonify(res)
Esempio n. 4
0
def api_v1_query_whois_get(query):
    res = query_whois(query)
    return Response(res, mimetype='text/plain')
Esempio n. 5
0
def whois_post():
    if not 'query' in request.form:
        return 'error'
    query = request.form['query']
    data = query_whois(query)
    return render_template('whois_response.html', data=data, title='WHOIS Result')
Esempio n. 6
0
def whois(query):
    accept = request.headers['Accept'].split(',')
    data = query_whois(query)
    if 'text/html' in accept:
        return render_template('whois_response.html', data=data, title='WHOIS Result')
    return Response(data, mimetype='text/plain')