Mercurial > hg > orthanc-stone
diff Resources/CodeGeneration/testWasmIntegrated/serve.py @ 498:6d62fc8a6988 bgo-commands-codegen
Web demonstrator for codegen ongoing work
author | bgo-osimis |
---|---|
date | Sun, 24 Feb 2019 13:23:14 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/CodeGeneration/testWasmIntegrated/serve.py Sun Feb 24 13:23:14 2019 +0100 @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# tested on python 3.4 ,python of lower version has different module organization. +# from https://gist.github.com/HaiyangXu/ec88cbdce3cdbac7b8d5 +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', + '.wasm': 'application/wasm', + '.css': 'text/css', + '.js': 'application/x-javascript', + '': 'application/octet-stream', # Default +} + +httpd = socketserver.TCPServer(("", PORT), Handler) + +print("serving at port", PORT) +httpd.serve_forever()