5 ms·
Ha, this is more like a puzzle than anything - trying to implement a protocol in a highly restrictive environment. For anyone looking for an easy way to spin u
by umvi 5y ago
Ha, this is more like a puzzle than anything - trying to implement a protocol in a highly restrictive environment.
For anyone looking for an easy way to spin up a command line web server, python has one built in, so if you are running linux usually you can do:
`python3 -m http.server`
From a terminal and it will spin up a web server that serves the current directory. I use this all the time for quick tinkering vs. installing/configuring nginx/node.js/caddy or whatever the cool kids are using these days.
- pcranaway 5y agoI use darkhttpd from time to time, it supports streaming: https://github.com/emikulic/darkhttpd https://github.com/emikulic/darkhttpd
- masklinn 5y agoThe biggest issue with `http.server` is it's a blocking single-threaded server, so it can serve a single client at a time. This makes it really really not great when trying to serve pages (with various attending static files), or to ad-hoc share large resources with other people on the network.
- javajosh 5y agoA single-threaded server is fine if you're only mildly IO bound, which is the case when you're serving files-as-resources. My understanding anyway is that http.server is explicitly not for production use!
- masklinn 5y ago> A single-threaded server is fine if you're only mildly IO bound, which is the case when you're serving files-as-resources. It's fine if you're also evented, but that's not the case here, http.server literally can only interact with one connection at a time, the next connection(s) will be queued up waiting for http.server to finish its thing and accept them. > My understanding anyway is that http.server is explicitly not for production use! Sure, but "I'm at a lan party and have the installer for $game so we don't explode the 'net connection" is not the sort of "production use" that's intended by this statement. Neither is "I want to open this HTML file I wrote which has a bunch of static assets booting up the webapp".
- londons_explore 5y agoIt also means a mis-configured client that doesn't close the connection can hang the server. Looking at you HttpClient-on-esp8266...
- jcims 5y agoWe had an engineer add it to his unit tests and started blaming the network team when everything started slowing down. Took me two days to convince him to try another server.
- teh_klev 5y agoParent does point out they use this for quick tinkering.
- masklinn 5y agoYes, and I point out issues I've hit when using this for quick tinkering.
- asiachick 5y agoand here's lots of alternatives since that solution has issues https://stackoverflow.com/questions/12905426/what-is-a-faster-alternative-to-pythons-http-server-or-simplehttpserver https://stackoverflow.com/questions/12905426/what-is-a-faste... Also, the python solution is only relevant if python is already installed. Something that's not true on Windows and is or will soon be true on MacOS.
- vimsee 5y agoWill Apple ditch Python in the future? Typing on an M1 Air and I`m pretty sure Python came per-installed.
- moreati 5y agomacOS 12 dropped PHP. It still has /usr/bin/python (CPython 2.7), but - any app the uses it triggers a message box about the the developer needing to update their app - before any REPL session it prints """ WARNING: Python 2.7 is not recommended. This version is included in macOS for compatibility with legacy software. Future versions of macOS will not include Python 2.7. Instead, it is recommended that you transition to using 'python3' from within Terminal. """ There is no version of Python 3 included with the OS. The XCode app/developer tools include Python 3.8. I expect macOS 13 won't include any Python interpreter out the box
- TingPing 5y agoWhy does it matter if it's included, it's trivial to install and extremely broadly useful?
- asiachick 5y agoI don't consider python trivial to install compared to other solutions. Python is much larger than many of the solutions listed in that S.O. thread.
- teh_klev 5y ago> Something that's not true on Windows. Getting python up an running on Windows is fairly trivial though. You don't even need local admin permissions if your machine is locked down by your IT dept.
- 0xbadcafebee 5y agoIf you have access to a busybox executable, it comes with a quite capable little httpd with /cgi-bin/ for CGI apps. If you have a wifi router, the web interface might be running off this :) (https://git.busybox.net/busybox/tree/networking/httpd.c https://git.busybox.net/busybox/tree/networking/httpd.c)
- makeworld 5y agoAnother option: https://github.com/blueness/sthttpd https://github.com/blueness/sthttpd