blob: 57bc133185357496c505a275cb629ff1ef2cb355 [file] [log] [blame]
Kevin Lubick29104522021-08-31 10:21:57 -04001#!/usr/bin/env python3
2# Copyright 2018 Google LLC
3#
Kevin Lubick3088c692020-04-24 15:06:19 -04004# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
Kevin Lubickf32ad082021-10-11 15:47:47 -04006#
7# This is a simple webserver that applies the correct MIME type for .wasm files.
Kevin Lubick3088c692020-04-24 15:06:19 -04008
Kevin Lubick29104522021-08-31 10:21:57 -04009import http.server
10import socketserver
Kevin Lubick3088c692020-04-24 15:06:19 -040011
Kevin Lubick29104522021-08-31 10:21:57 -040012PORT = 8000
Kevin Lubick3088c692020-04-24 15:06:19 -040013
Kevin Lubick29104522021-08-31 10:21:57 -040014class Handler(http.server.SimpleHTTPRequestHandler):
Kevin Lubick3088c692020-04-24 15:06:19 -040015 pass
16
17Handler.extensions_map['.js'] = 'application/javascript'
18# Without the correct MIME type, async compilation doesn't work
19Handler.extensions_map['.wasm'] = 'application/wasm'
20
Kevin Lubick29104522021-08-31 10:21:57 -040021httpd = socketserver.TCPServer(("", PORT), Handler)
Kevin Lubick3088c692020-04-24 15:06:19 -040022
23httpd.serve_forever()