Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Perhaps this would be a good place to tie into the "Accept:" request header? If it says text/html in Accept:, you're still going to return JSON, but you can use this as a hint that it is probably being read by a human, and you can pretty print it.

But if you see application/json in Accept:, then you assume it's an API call from a phone or script and you minify it instead.

Edit: however, that requires cooperation from others, so is prone to failure. Perhaps also take hints from the user agent string?

Edit 2: drat, someone already beat me to this suggestion. However, I'll use this as an excuse to pimp my last weekend hack: adding an Accept: decorator to itty.py http://news.ycombinator.com/item?id=3665743



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: