
Show HN: Serve – like python -m SimpleHTTPServer, but with gzip and http2 - rhardih
https://github.com/rhardih/serve
======
earthboundkid
This doesn't make any sense to me. And I've written a Go reverse proxy server
[https://github.com/carlmjohnson/simple-reverse-
proxy](https://github.com/carlmjohnson/simple-reverse-proxy) .

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."

~~~
rhardih
_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.

------
chatmasta
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.

~~~
WorldMaker
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.

------
Socketubs
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.

~~~
rhardih
I couldn't fit all that in the title though. :)

Joking aside, you are correct. Go shipping pre-installed is a yet to be seen
nice-to-have on most systems.

