Search code examples
pythoncherrypyweb-frameworks

Distinguishing between GET and POST data in CherryPy?


I've been deciding between Python web frameworks for a project of mine and I've really liked how lightweight, flexible, and concise CherryPy is compared to others. The only problem I'm having is I can't find any documentation on how to distinguish between data sent via GET and via POST.

For example, I don't want users to be able to provide their login credentials through a GET request (http://example.com/login?username=user&password=pass) but, according to CherryPy's tutorial, all data is sent as method parameters, no matter what HTTP method they're sent as. Is there some way to say I only want the POST data or do I have to use MethodDispatcher?

Thanks!


Solution

  • See the docs.

    A string containing the HTTP method, such as "GET" or "POST". Set in the "run" phase.

    looks like checking cherrypy.request.method is what you want to do.