alphanumeric alphanumeric - 1 year ago 72
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?

Answer Source

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


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download