Show HN: Serve – like python -m SimpleHTTPServer, but with gzip and http2
github.com
github.com
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.
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.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.
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.
Joking aside, you are correct. Go shipping pre-installed is a yet to be seen nice-to-have on most systems.