10

I'm new to web.py. I used PHP alot. In PHP, POST parameter and GET parameter is stored in different global variables

For example:

curl http://127.0.0.1/test?get_param1=1 -d 'post_param1=2'

In PHP you can get $_GET['get_param1'] is 1 and $_POST['post_param1'] is 2.

But it seems impossible to distinct GET/POST parameters in web.py?

I can only use web.input() to get GET/POST parameters in a dict-like object, but I cannot tell which of them is from the query string and which is from POST data

Liam
  • 6,009
  • 4
  • 39
  • 53
yegle
  • 5,795
  • 6
  • 39
  • 61

1 Answers1

17

There's actually an (undocumented?) _method parameter that can be get, post or both (the default) to return variables from the different sources. See the source for web.input(). So for example:

get_input = web.input(_method='get')
post_input = web.input(_method='post')

However, I've used web.py a lot, and never needed this. Why do you need to distinguish between input parameters in the query string and the data?

Ben Hoyt
  • 10,694
  • 5
  • 60
  • 84
  • Just wondering if this worked or helped? If so, please mark the answer as accepted or vote it up, respectively. – Ben Hoyt May 08 '12 at 01:48