Kevin Lubick | 2910452 | 2021-08-31 10:21:57 -0400 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # Copyright 2018 Google LLC |
| 3 | # |
Kevin Lubick | 3088c69 | 2020-04-24 15:06:19 -0400 | [diff] [blame] | 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
Kevin Lubick | f32ad08 | 2021-10-11 15:47:47 -0400 | [diff] [blame] | 6 | # |
| 7 | # This is a simple webserver that applies the correct MIME type for .wasm files. |
Kevin Lubick | 3088c69 | 2020-04-24 15:06:19 -0400 | [diff] [blame] | 8 | |
Kevin Lubick | 2910452 | 2021-08-31 10:21:57 -0400 | [diff] [blame] | 9 | import http.server |
| 10 | import socketserver |
Kevin Lubick | 3088c69 | 2020-04-24 15:06:19 -0400 | [diff] [blame] | 11 | |
Kevin Lubick | 2910452 | 2021-08-31 10:21:57 -0400 | [diff] [blame] | 12 | PORT = 8000 |
Kevin Lubick | 3088c69 | 2020-04-24 15:06:19 -0400 | [diff] [blame] | 13 | |
Kevin Lubick | 2910452 | 2021-08-31 10:21:57 -0400 | [diff] [blame] | 14 | class Handler(http.server.SimpleHTTPRequestHandler): |
Kevin Lubick | 3088c69 | 2020-04-24 15:06:19 -0400 | [diff] [blame] | 15 | pass |
| 16 | |
| 17 | Handler.extensions_map['.js'] = 'application/javascript' |
| 18 | # Without the correct MIME type, async compilation doesn't work |
| 19 | Handler.extensions_map['.wasm'] = 'application/wasm' |
| 20 | |
Kevin Lubick | 2910452 | 2021-08-31 10:21:57 -0400 | [diff] [blame] | 21 | httpd = socketserver.TCPServer(("", PORT), Handler) |
Kevin Lubick | 3088c69 | 2020-04-24 15:06:19 -0400 | [diff] [blame] | 22 | |
| 23 | httpd.serve_forever() |