python - How to get sender info from request object -
with 3 <a>
calling same function:
<a id="1" href="call" 1 </a> <a id="2" href="call" 2 </a> <a id="3" href="call" 3 </a>
on back-end in python using flask looks this:
@app.route("/call") def call(): print request
now inside of python call()
function request
object. can use request
idea of 3 <a>
clicked call function?
you can't information cliked link request. have add unique argument every link ie. href="call?number=1"
or href="call/1"
, can number
in flask.
href="call?number=1"
needs
@app.route("/call") def call(): print request.args.get('number', 'no number!')
see: http://flask.pocoo.org/docs/0.11/quickstart/#the-request-object
href="call/1"
needs
@app.route("/call/<int:val>") def call(val): print val
see: http://flask.pocoo.org/docs/0.11/quickstart/#variable-rules
Comments
Post a Comment