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')
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')
def api_v1_query_whois(): query = request.json['query'] res = { 'raw': query_whois(query) } return jsonify(res)
def api_v1_query_whois_get(query): res = query_whois(query) return Response(res, mimetype='text/plain')
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')
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')