Skip to content

http.server: Update default extensions_map to include .wasmย #106900

@vadimkantorov

Description

@vadimkantorov

Then python -m http.server is suitable for experimenting with WASM/Emscripten projects. Currently people need to roll their own scripts like https://github.com/python/cpython/blob/main/Tools/wasm/wasm_webserver.py

Here are the default extensions_map (btw could include text/html, text/javascript, text/xml, text/json or other popular extensions for debugging very simple static web app projects):

cpython/Lib/http/server.py

Lines 661 to 666 in a1a3193

extensions_map = _encodings_map_default = {
'.gz': 'application/gzip',
'.Z': 'application/octet-stream',
'.bz2': 'application/x-bzip2',
'.xz': 'application/x-xz',
}

Adding MIME for .data by default is also nice for this is a file extension of Emscripten file system data packages.

It would also be nice if the default http server can be made multi-threaded, because in some rare circumstances it can block Emscripten data package loading. I rolled my own server https://gist.github.com/vadimkantorov/a8c3aca556824df061e84b1d10edee44 which also was serving ETag / HTTP 304 properly.

At least it would be nice to support customizing extensions_map in http.server command line, so that one can call python -m http.server --map-mime .wasm:application/wasm --map-mime .data:application/octet-stream --serve-permanent-etag

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-emscriptenOS-wasistdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions