-
Notifications
You must be signed in to change notification settings - Fork 3
/
infinite-html.py
executable file
·49 lines (35 loc) · 1.05 KB
/
infinite-html.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
# Came about testing IRC bots scraping titles from links.
# nginx config to proxy to this script:
# server {
# server_name infinite.nijotz.com;
# location / { proxy_pass http://localhost:8080; }
# }
import sys
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from SocketServer import ThreadingMixIn
class ThreadingServer(ThreadingMixIn, HTTPServer):
pass
class InfiniteGarbage(BaseHTTPRequestHandler):
def _garbage(self):
self.send_response(200)
self.send_header('Content-Type', 'text/html')
self.end_headers()
garbage = 'HUE HUE HUE '
while True:
self.wfile.write(garbage)
def do_GET(self):
self._garbage()
def do_POST(self):
self._garbage()
def do_HEAD(self):
self._garbage()
if __name__ == '__main__':
port = 8080
if len(sys.argv) >= 2:
port = int(sys.argv[1])
gahbage = ThreadingServer(('', port), InfiniteGarbage)
try:
gahbage.serve_forever()
finally:
gahbage.socket.close()