Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Request' object has no attribute 'get' Python error

I am trying to get a url parameter in Python.

I am using this code:

from flask import request, url_for, redirect
# ...
controller = request.get('controller')

but I am getting this error:

'Request' object has no attribute 'get'

Any ideas?

Thanks

like image 290
kbaccouche Avatar asked Apr 25 '12 16:04

kbaccouche


1 Answers

You want to use request.args for your GET parameters in Flask. Here is a quote with an example from the Accessing Request Data section of the Quickstart document.


To access parameters submitted in the URL (?key=value) you can use the args attribute:

searchword = request.args.get('key', '')    
like image 76
istruble Avatar answered Sep 23 '22 17:09

istruble