Skip to content

Instantly share code, notes, and snippets.

@hailangx
Created May 18, 2014 14:00
Show Gist options
  • Save hailangx/ec88cbdce3cdbac7b8d5 to your computer and use it in GitHub Desktop.
Save hailangx/ec88cbdce3cdbac7b8d5 to your computer and use it in GitHub Desktop.

Revisions

  1. @haiyangxu haiyangxu created this gist May 18, 2014.
    25 changes: 25 additions & 0 deletions Server.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    # -*- coding: utf-8 -*-
    #test on python 3.4 ,python of lower version has different module organization.
    import http.server
    from http.server import HTTPServer, BaseHTTPRequestHandler
    import socketserver

    PORT = 8080

    Handler = http.server.SimpleHTTPRequestHandler

    Handler.extensions_map={
    '.manifest': 'text/cache-manifest',
    '.html': 'text/html',
    '.png': 'image/png',
    '.jpg': 'image/jpg',
    '.svg': 'image/svg+xml',
    '.css': 'text/css',
    '.js': 'application/x-javascript',
    '': 'application/octet-stream', # Default
    }

    httpd = socketserver.TCPServer(("", PORT), Handler)

    print("serving at port", PORT)
    httpd.serve_forever()