python https server


SUBMITTED BY: Guest

DATE: Dec. 12, 2013, 8:21 a.m.

FORMAT: Python

SIZE: 532 Bytes

HITS: 1064

  1. import SimpleHTTPServer
  2. import BaseHTTPServer
  3. import ssl
  4. class MyRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
  5. def do_GET(self):
  6. if self.path == '/':
  7. self.path = 'test.html'
  8. return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
  9. Handler = MyRequestHandler
  10. server = BaseHTTPServer.HTTPServer(('localhost', 8080), Handler)
  11. server.socket = ssl.wrap_socket(server.socket, certfile='server.pem', server_side=True)
  12. server.serve_forever()

comments powered by Disqus