20

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

5
  • Are you using a web framework? Commented Apr 25, 2012 at 16:57
  • What type is the request object? Commented Apr 25, 2012 at 16:59
  • I get request like this : from flask import request, url_for, redirect Commented Apr 25, 2012 at 17:02
  • Well, that is a good information, that it is Flask :-). Commented Apr 25, 2012 at 17:03
  • Sorry, I don't know Python at all. I'm trying to use this code in my aplication github.com/dailymotion/cloudkey-py/blob/master/examples/… Commented Apr 25, 2012 at 17:05

1 Answer 1

22

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', '')    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.