forked from qiyeboy/IPProxyPool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesthttpserver.py
More file actions
48 lines (44 loc) · 1.57 KB
/
Copy pathtesthttpserver.py
File metadata and controls
48 lines (44 loc) · 1.57 KB
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
# coding:utf-8
import BaseHTTPServer
import json
import urlparse
class WebRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
"""
"""
print
self.path
parsed_path = urlparse.urlparse(self.path)
print
parsed_path
print
parsed_path.query
# message_parts = [
# 'CLIENT VALUES:',
# 'client_address=%s (%s)' % (self.client_address,
# self.address_string()),
# 'command=%s' % self.command,
# 'path=%s' % self.path,
# 'real path=%s' % parsed_path.path,
# 'query=%s' % parsed_path.query,
# 'request_version=%s' % self.request_version,
# '',
# 'SERVER VALUES:',
# 'server_version=%s' % self.server_version,
# 'sys_version=%s' % self.sys_version,
# 'protocol_version=%s' % self.protocol_version,
# '',
# 'HEADERS RECEIVED:',
# ]
# for name, value in sorted(self.headers.items()):
# message_parts.append('%s=%s' % (name, value.rstrip()))
# message_parts.append('')
# message = '\r\n'.join(message_parts)
data1 = [{'ip': '192.168.0.0', 'port': 456}] * 10
d1 = json.dumps(data1, sort_keys=True, indent=4)
message = ('192.168.1.1', 80)
self.send_response(200)
self.end_headers()
self.wfile.write(d1)
server = BaseHTTPServer.HTTPServer(('0.0.0.0', 8000), WebRequestHandler)
server.serve_forever()