5 ms·
Nobody seems to have posted this yet: python -m SimpleHTTPServer I'd recommend an alias like "serve". It basically puts the current directory online (bind
by ancarda 13y ago
Nobody seems to have posted this yet:
python -m SimpleHTTPServer
I'd recommend an alias like "serve". It basically puts the current directory online (binds to 0.0.0.0:8000).
- verandaguy 13y agoAm I wrong to have long dismissed this as little more than an easter egg, or, at best, a toy server to test basic webpage functionality?
- ramses0 13y agoYes. It's like a ghetto SCP for giving files to people on windows who don't have SCP. You can use it for basic web functionality, you can use it (carefully) as a mechanism for testing or serving test results. I wouldn't keep it running for days, but it's an amazingly useful tool.
- verandaguy 13y agoWhoa, never thought of it that way. The makeshift SCP is really a good idea!
- ancarda 13y agoI use it quite a lot to move files between my computers, stream content to my phone, test out web designs. I suppose it's like net cat, it's useful for some. I think "toy server" is fairly accurate, I can't see anyone using this in production but I can't see people installing nginx on their laptops either.
- kalleboo 13y ago> I can't see people installing nginx on their laptops either. OS X comes with apache preinstalled though
- thom 13y agoThe only problem it really solves is if you've got non-relative paths in your HTML/CSS. I've used this a couple of times in those situations.
- umanwizard 13y agoJust because that's the only problem you use it to solve doesn't mean that's the only problem it solves.
- thom 13y agoSorry, wasn't trying to belittle anything (I've actually written a Mac menu bar app that does this exact thing which a couple of designer friends use).
- tantaman 13y agoDepends on what you're developing. If you're doing single page apps that get their data from an external service then this is incredibly useful.
- deleted 13y ago[deleted]
- umanwizard 13y agoOur build process automatically generates a directory tree of HTML-formatted unit test coverage reports. Sometimes it's nice to be able to share links to those reports in a code review. I use python SimpleHTTPServer for that.
- stiller 13y agoOr in Ruby: ruby -run -e httpd . -p 8000
- MrBuddyCasino 13y agoRelated: python -m smtpd -n -c DebuggingServer localhost:25 A makeshift SMTP server that logs all messages to the console.
- pi-rat 13y agoIt does not support large files, so sometimes I have to fall back to https://npmjs.org/package/http-server https://npmjs.org/package/http-server (npm -g install http-server .. then just run http-server /path)
- skyebook 13y agoMind blown. Thanks!
- stock_toaster 13y agosimilarly, you can get a janky json pretty printer by doing: curl -s http://some/json/url | python -m json.tool
- wging 13y agoWhen your needs stretch beyond that, try 'jq'. http://stedolan.github.io/jq/ http://stedolan.github.io/jq/ For pretty-printing without modification, cat myjson | jq '.'
- p8952 13y agoOr for Python3: python -m http.server . Or Ruby: ruby -run -e httpd .