Blame view

dfu-web/webdfu-gh-pages/SimpleSecureHTTPServer.py 733 Bytes
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  #!/usr/bin/python
  import BaseHTTPServer, SimpleHTTPServer
  import ssl
      
  def run(args):
      httpd = BaseHTTPServer.HTTPServer((args.hostname, args.port), SimpleHTTPServer.SimpleHTTPRequestHandler)
      httpd.socket = ssl.wrap_socket(httpd.socket, certfile=args.cert, server_side=True)
      name, addr = httpd.socket.getsockname()
      print("Serving HTTPS on {} port {}...".format(name, addr))
      httpd.serve_forever()
  
  if __name__ == '__main__':
      import argparse
      parser = argparse.ArgumentParser()
      parser.add_argument("--hostname", default="172.26.145.168")
      parser.add_argument("--port", type=int, default=443)
      parser.add_argument("--cert", default="server.pem")
  
      args = parser.parse_args()
      
      run(args)