~kaijanmaki/+junk/indicators-ng

« back to all changes in this revision

Viewing changes to zinc/bin/http-server

  • Committer: Antti Kaijanmäki
  • Date: 2016-03-11 16:45:46 UTC
  • mfrom: (21.1.2 indicators-ng)
  • Revision ID: antti.kaijanmaki@canonical.com-20160311164546-v4iy2mgu5s40m2fy
merge upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python3
 
2
 
 
3
import http.server
 
4
 
 
5
class ProxyHTTPRequestHandler(http.server.BaseHTTPRequestHandler):
 
6
    def printstuff(self):
 
7
        print('Client Address:', self.client_address)
 
8
        print('Command:       ', self.command)
 
9
        print('Path:          ', self.path)
 
10
 
 
11
    def do_GET(self):
 
12
        print("Handling request!")
 
13
        self.printstuff()
 
14
        self.send_response(200)
 
15
        self.end_headers()
 
16
 
 
17
        message = "Hello world!"
 
18
        self.wfile.write(bytes(message, "utf8"))
 
19
 
 
20
httpd = http.server.HTTPServer(('', 8001), ProxyHTTPRequestHandler)
 
21
httpd.serve_forever()