It's like `python3 -m http.server` but in a language that is rarely pre-installed on systems with an external program that has two external dependencies.
Or `http-server` from `npm install -g http-server` in a language that frontend developers and increasing numbers of backend developers actually work with.
That said, HTTP/2 support might be nice to have in Python's http.server or Node's http-server. Albeit you probably shouldn't use http.server nor http-server for production purposes, so it isn't essential.
If you have python-twisted installed, you can also use this one-liner:
python -c 'from twisted.web.server import Site; from twisted.web.static import File; from twisted.internet import reactor; reactor.listenTCP(4545, Site(File("/your/static/file/directory/"))); reactor.run()'
I was unable to watch HTML5 video using the `python -m SimpleHTTPServer`, but with twisted it works. Not sure why but it's somehow related to streaming content.
Easiest explanation is MIME type information. http.server module has only the bare minimum support for MIME types. Per standards things like HTML5 video tag are very reliant on MIME type information. I'd be willing to guess twisted handles a lot more MIME types.
Next most likely after that would probably be CORS which is also a HTTP header issue that something like 'http.server' implements only the bare minimum for.
Of course both of those are just a guess. If you had captured the output of your browser's dev console/F12 tools you likely would have seen what specifically your particularly browser was complaining about.
Python's SimpleHTTPServer is for when you have some directory on your computer and you want to test it locally in the browser. That's all. So, there's no reason to use GZIP or HTTP2 with a SimpleHTTPServer replacement. If you need those features, it's because you're doing things _in production_, in which case you should use Nginx, Apache, or Caddy (if you really want to use something Go-based).
Python's SimpleHTTPServer is for when you have some directory on your computer and you want to test it locally in the browser. That's all.
That is however, the same intended purpose as this tool.
So, there's no reason to use GZIP or HTTP2 with a SimpleHTTPServer replacement. If you need those features, it's because you're doing things _in production_
Call me old fashioned, but I find it useful to know what a request would look like served from a production setting, without actually having to get it from production.
If you're optimising for load times, the final size of a gzipped request matters greatly. It's nice to know if you're within the 14kb boundary before pushing out.
HTTP/2 is a completely different beast as well. Since this is mostly for working on static sites, odds are you might host on a CDN with static file caches. If you've optimised your site for HTTP/1.1, bundling, inlining etc., but the the edge of the CDN actually serves these files as HTTP/2, you're very likely to have worked against the performance improvements given to you by HTTP/2.
7 comments
[ 0.21 ms ] story [ 26.6 ms ] threadThat said, HTTP/2 support might be nice to have in Python's http.server or Node's http-server. Albeit you probably shouldn't use http.server nor http-server for production purposes, so it isn't essential.
Joking aside, you are correct. Go shipping pre-installed is a yet to be seen nice-to-have on most systems.
Next most likely after that would probably be CORS which is also a HTTP header issue that something like 'http.server' implements only the bare minimum for.
Of course both of those are just a guess. If you had captured the output of your browser's dev console/F12 tools you likely would have seen what specifically your particularly browser was complaining about.
Python's SimpleHTTPServer is for when you have some directory on your computer and you want to test it locally in the browser. That's all. So, there's no reason to use GZIP or HTTP2 with a SimpleHTTPServer replacement. If you need those features, it's because you're doing things _in production_, in which case you should use Nginx, Apache, or Caddy (if you really want to use something Go-based).
TL;DR: If you need GZIP/HTTP2, it's not "simple."
That is however, the same intended purpose as this tool.
So, there's no reason to use GZIP or HTTP2 with a SimpleHTTPServer replacement. If you need those features, it's because you're doing things _in production_
Call me old fashioned, but I find it useful to know what a request would look like served from a production setting, without actually having to get it from production.
If you're optimising for load times, the final size of a gzipped request matters greatly. It's nice to know if you're within the 14kb boundary before pushing out.
HTTP/2 is a completely different beast as well. Since this is mostly for working on static sites, odds are you might host on a CDN with static file caches. If you've optimised your site for HTTP/1.1, bundling, inlining etc., but the the edge of the CDN actually serves these files as HTTP/2, you're very likely to have worked against the performance improvements given to you by HTTP/2.