Bottle request.forms.get returns None

I am trying to submit information from a web form in python using a bottle. I use get to send the variable "test", but when I call the query function for "test", it does not return anything. I am using a bottle tutorial as my reference.

Here is my web form:

<form action="http://localhost:8080/page" method="get">
<input type="number" name="test" step="5">
<input type="submit" name="my-form" value="GO">
</form>

If you enter 1 in the field and click go, this will result in the following URL:

http://localhost:8080/page?test=10&my-form=GO

And here is the python code for the bottle:

@route('/page', method='GET')
def index():
testvar = request.forms.get('test')
return 'Hello %s' % testvar

From what I understand, request.forms.get ('test') should extract the value from test = 10 in the url and pass it to testvar. However, I get a value of none, i.e. var is empty.

Thanks!

+4
source share
2

, request.forms POST PUT:

, URL- POST PUT . FormsDict. .

HTTP GET, request.params.

+3

HTTP GET, , . Bottle request.query :

query_string FormsDict. "URL-" " GET", " URL", .

request.forms HTTP POST:

URL- /- POST PUT. FormsDict. . .

+2

Source: https://habr.com/ru/post/1624803/


All Articles