498
|
1 # -*- coding: utf-8 -*-
|
|
2 # tested on python 3.4 ,python of lower version has different module organization.
|
|
3 # from https://gist.github.com/HaiyangXu/ec88cbdce3cdbac7b8d5
|
|
4 import http.server
|
|
5 from http.server import HTTPServer, BaseHTTPRequestHandler
|
|
6 import socketserver
|
|
7
|
|
8 PORT = 8080
|
|
9
|
|
10 Handler = http.server.SimpleHTTPRequestHandler
|
|
11
|
|
12 Handler.extensions_map = {
|
|
13 '.manifest': 'text/cache-manifest',
|
|
14 '.html': 'text/html',
|
|
15 '.png': 'image/png',
|
|
16 '.jpg': 'image/jpg',
|
|
17 '.svg': 'image/svg+xml',
|
|
18 '.wasm': 'application/wasm',
|
|
19 '.css': 'text/css',
|
|
20 '.js': 'application/x-javascript',
|
|
21 '': 'application/octet-stream', # Default
|
|
22 }
|
|
23
|
|
24 httpd = socketserver.TCPServer(("", PORT), Handler)
|
|
25
|
|
26 print("serving at port", PORT)
|
|
27 httpd.serve_forever()
|