aboutsummaryrefslogtreecommitdiffstats
path: root/server.py
diff options
context:
space:
mode:
Diffstat (limited to 'server.py')
-rw-r--r--server.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/server.py b/server.py
index ae4dcda..072ed22 100644
--- a/server.py
+++ b/server.py
@@ -17,6 +17,7 @@ import socket
import socks, sockshandler
import subprocess
import re
+import sys
@@ -122,12 +123,21 @@ def site_dispatch(env, start_response):
return
-
+class FilteredRequestLog:
+ '''Don't log noisy thumbnail and avatar requests'''
+ filter_re = re.compile(r'"GET /https://(i\.ytimg\.com/|www.youtube\.com/data/subscription_thumbnails/|yt3.ggpht.com/).*" 200')
+ def __init__(self):
+ pass
+ def write(self, s):
+ if not self.filter_re.search(s):
+ sys.stderr.write(s)
if settings.allow_foreign_addresses:
- server = WSGIServer(('0.0.0.0', settings.port_number), site_dispatch)
+ server = WSGIServer(('0.0.0.0', settings.port_number), site_dispatch,
+ log=FilteredRequestLog())
else:
- server = WSGIServer(('127.0.0.1', settings.port_number), site_dispatch)
+ server = WSGIServer(('127.0.0.1', settings.port_number), site_dispatch,
+ log=FilteredRequestLog())
print('Started httpserver on port ' , settings.port_number)
server.serve_forever()