alphanumeric alphanumeric - 3 months ago 23
HTML Question

How to get sender info from request object

With three

all calling the same function:

<a id="1" href="call" One </a>
<a id="2" href="call" Two </a>
<a id="3" href="call" Three </a>

On a back-end in python using Flask it looks like this:

def call():
print request

Now inside of Python
function I get a
object. Can I use this
to get idea which of three
were clicked to call the function?


You can't get information about cliked link from request. You have to add unique argument to every link ie. href="call?number=1" or href="call/1" and then you can get number in Flask.

href="call?number=1" needs

def call():
    print request.args.get('number', 'no number!')


href="call/1" needs

def call(val):
    print val