mininet-sample/utils/http_server.py

27 lines
746 B
Python
Raw Normal View History

2015-12-01 16:48:32 +00:00
'''
From :
http://code.activestate.com/recipes/442473-simple-http-server-supporting-ssl-secure-communica/
SimpleHTTPServer.py - simple HTTP server supporting SSL.
- the default port is 80.
usage: python SimpleHTTPServer.py
'''
2020-06-25 12:56:47 +00:00
import sys
if sys.version_info[0] == 3:
2020-06-24 14:11:54 +00:00
# Python 3
2020-06-25 12:56:47 +00:00
import http.server
server_address = ('', 80)
httpd = http.server.HTTPServer(server_address, http.server.SimpleHTTPRequestHandler)
print("Serving HTTP on 0.0.0.0 port 80...")
2015-12-01 16:48:32 +00:00
httpd.serve_forever()
2020-06-25 12:56:47 +00:00
else:
# Python2
import BaseHTTPServer, SimpleHTTPServer
import os
httpd = BaseHTTPServer.HTTPServer(('', 443), SimpleHTTPServer.SimpleHTTPRequestHandler)
print("Serving HTTP on 0.0.0.0 port 80...")
httpd.serve_forever()