From fc58403a0187e4c707d46a0f5fe9a80f3852e791 Mon Sep 17 00:00:00 2001 From: Jordan Date: Fri, 21 Jun 2019 18:05:48 -0700 Subject: readme, relays.py trailing whitespace --- README.md | 10 ++++++++++ tor-metrics/relays.py | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e8c7bf7..e6bc48c 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,16 @@ Network-oriented Tor metrics and statistics made with love (not javascript). * Sort by ASN, country, and platform * Respectful Onionoo queries (If-Modified-Since) +```bash +# Requirements: python3, jinja2 (pip install jinja2) + +git clone https://github.com/tempname1024/tor-metrics.git +cd tor-metrics/tor-metrics +python3 generate.py + +# Files are written to www/ by default +``` + ``` TODO: - Per-relay page generation (display contact, exit policy, etc) diff --git a/tor-metrics/relays.py b/tor-metrics/relays.py index 31f4bd9..2c88528 100644 --- a/tor-metrics/relays.py +++ b/tor-metrics/relays.py @@ -17,7 +17,7 @@ class Relays: with open(self.ts_file, 'r') as ts_file: prev_timestamp = ts_file.read() try: - conn = urllib.request.Request(self.url, + conn = urllib.request.Request(self.url, headers={"If-Modified-Since": prev_timestamp}) api_response = urllib.request.urlopen(conn).read() self.statuscode = urllib.request.urlopen(conn).getcode() @@ -36,7 +36,7 @@ class Relays: return(None) except URLError as e: return(None) - + json_data = json.loads(api_response.decode('utf-8')) sorted_json = self.sort_by_bandwidth(json_data) trimmed_json = self.trim_platform(sorted_json) -- cgit v1.2.3-54-g00ecf