title: Route requests based on the Accept header in Python web frameworks
body: <p>I have some experience with different web frameworks (Django, web.py, Pyramid and CherryPy), and I'm wondering in which one will it be easier and hopefully cleaner to implement a route dispatcher to a different "view/handler" based on the "Accept" header and the HTTP method e.g.:</p>
  
  <pre><code>Accept: application/json
  POST /post/
  </code></pre>
  
  <p>is handled different than:</p>
  
  <pre><code>Accept: text/html
  POST /post/
  </code></pre>
  
  <p>So the request gets routed to the particular view of the corresponding handler of the MIME "application/json" and the HTTP method "POST".</p>
  
  <p>I do know how to implement something like that in CherryPy, but I lose the use of the CherryPy tools for the internal redirection of the request because I'm calling the specific method directly instead of automagically from the dispatcher. Another option is to implement a full new dispatcher from scratch, but that's the last option.</p>
  
  <p>I'm aware of the alternative to use extensions in the url  like <code>/post.json</code> or <code>/post/.json</code>, but I'm looking to keep the same url?</p>