Created
December 22, 2017 13:35
-
-
Save kabinpokhrel/6fd1275603e9d5f1e284be717cbd1bff to your computer and use it in GitHub Desktop.
Simple HTTP Server Implementation in Python 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import http.server as httpserver | |
import socketserver | |
def main(port=None): | |
if port is None: | |
port = 8000 | |
handler = httpserver.SimpleHTTPRequestHandler | |
try: | |
httpd = socketserver.TCPServer(("", port), handler) | |
print("serving at port", port) | |
httpd.serve_forever() | |
except OSError: | |
print("Given PORT:{} is unavailable.Try running with diffrent PORT Number!".format(port)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment