aboutsummaryrefslogtreecommitdiffstats
path: root/server.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2020-08-12 14:37:32 -0700
committerJames Taylor <user234683@users.noreply.github.com>2020-08-12 14:37:32 -0700
commit3a07a87c88b27c5e7e06ee7d67cd6095272e9159 (patch)
tree62352049459cd7ebee14bec7a7abf1985774f113 /server.py
parent3fccc39e3271ea143844d84b2cefa047ebf84c0e (diff)
downloadyt-local-3a07a87c88b27c5e7e06ee7d67cd6095272e9159.tar.lz
yt-local-3a07a87c88b27c5e7e06ee7d67cd6095272e9159.tar.xz
yt-local-3a07a87c88b27c5e7e06ee7d67cd6095272e9159.zip
Don't log noisy thumbnail and avatar requests in the console
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()