Lurker News
OSX Terminal: hold option and click a position in the current line to move your cursor to that position. #yearslost

Comments (395) 107 threads

Show all comments

Showing thread 5 of 107

ancarda6 replies#
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).
verandaguy5 replies#
Am 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?
ramses01 reply#
Yes. 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#
Whoa, never thought of it that way. The makeshift SCP is really a good idea!
ancarda1 reply#
I 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#
> I can't see people installing nginx on their laptops either.

OS X comes with apache preinstalled though

thom1 reply#
The 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.
School-Cotton1 reply#
Just because that's the only problem you use it to solve doesn't mean that's the only problem it solves.
thom#
Sorry, 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#
Depends 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.
School-Cotton#
Our 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.
MrBuddyCasino#
Related:

  python -m smtpd -n -c DebuggingServer localhost:25
A makeshift SMTP server that logs all messages to the console.
skyebook#
Mind blown. Thanks!
stock_toaster1 reply#
similarly, you can get a janky json pretty printer by doing:

   curl -s http://some/json/url | python -m json.tool
wging#
When your needs stretch beyond that, try 'jq'. http://stedolan.github.io/jq/

For pretty-printing without modification,

    cat myjson | jq '.'
p8952#
Or for Python3: python -m http.server .

Or Ruby: ruby -run -e httpd .