From d399e1b684c1e19edcbb0dac9f0aaa40e0842443 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sat, 22 Sep 2012 22:26:47 +0200 Subject: [PATCH] Also show a raw WHOIS response when available --- app.py | 16 +++++++++++----- static/style.css | 7 +++++++ templates/result.tpl | 10 +++++++++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 0cbaa36..c717692 100644 --- a/app.py +++ b/app.py @@ -67,7 +67,12 @@ def find_whois(domain): db_results = db['responses'].find_one({'domain': domain}) if db_results is not None: - return (db_results['timestamp'], db_results['response']) + try: + raw = db_results['raw'] + except KeyError: + raw = None + + return (db_results['timestamp'], db_results['response'], raw) else: raw, result = whois(domain) @@ -79,7 +84,7 @@ def find_whois(domain): 'raw': raw }) - return (time.time(), result) + return (time.time(), result, raw) else: return (time.time(), None) @@ -99,20 +104,21 @@ def query(): @app.route('/query/html/', methods=["GET"]) def query_html(domain): - retrieval_date, result = find_whois(domain) + retrieval_date, result, raw = find_whois(domain) if result is None: flash("The specified domain does not exist.") return render_template("home.tpl"), 404 else: retrieval_timestamp = datetime.datetime.fromtimestamp(int(retrieval_date)) - return render_template("result.tpl", domain=domain, retrieval_date=retrieval_timestamp.isoformat(), **result) + + return render_template("result.tpl", domain=domain, retrieval_date=retrieval_timestamp.isoformat(), raw=raw, **result) @app.route('/query/json/', methods=["GET"]) def query_json(domain): if domain is not None: - retrieval_date, result = find_whois(domain) + retrieval_date, result, raw = find_whois(domain) result['retrieval_date'] = int(retrieval_date) diff --git a/static/style.css b/static/style.css index eb83dc2..0e3ffa4 100644 --- a/static/style.css +++ b/static/style.css @@ -102,3 +102,10 @@ table { color: #FFFB85; } + +pre +{ + background-color: #DEDEDE; + border: 1px solid gray; + padding: 7px; +} diff --git a/templates/result.tpl b/templates/result.tpl index b913d13..3eb1f53 100644 --- a/templates/result.tpl +++ b/templates/result.tpl @@ -56,7 +56,15 @@

- Need JSON? Try http://whois.cryto.net/query/json/{{ domain }} + Need JSON? Try http://whois.cryto.net/query/json/{{ domain }}

+ {% if raw != None %} +

Raw WHOIS response

+
+{% autoescape true %}
+{{ raw }}
+{% endautoescape %}
+
+ {% endif %} {% endblock %}