Skip to content

Instantly share code, notes, and snippets.

@pshirshov
Forked from guenter/http.py
Created May 26, 2015 12:13
Show Gist options
  • Select an option

  • Save pshirshov/2c8e5be01f1488a87d0b to your computer and use it in GitHub Desktop.

Select an option

Save pshirshov/2c8e5be01f1488a87d0b to your computer and use it in GitHub Desktop.

Revisions

  1. Fei Wong Reed renamed this gist May 26, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @guenter guenter created this gist Nov 14, 2013.
    17 changes: 17 additions & 0 deletions http.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    import sys

    port = 8080

    if sys.version_info.major == 3:
    import http.server
    import socketserver
    handler = http.server.SimpleHTTPRequestHandler
    httpd = socketserver.TCPServer(("",port), handler)
    elif sys.version_info.major == 2:
    import SimpleHTTPServer
    import SocketServer
    handler = SimpleHTTPServer.SimpleHTTPRequestHandler
    httpd = SocketServer.TCPServer(("",port), handler)

    print("Serving at port %d\n" % port)
    httpd.serve_forever()