flask parameter passing problem

Method a:
A = the href ''? / Edit_grade / g_id1 = {{<g_ID>}} ''
In this way parameter passing, a rear end directly as parameters in the GET request, then the path from the distal end request.args. get ( 'g_id1') get the value, the parameter values do not need to pass in the view function.

@app.route('/get',methods=['GET','POST'])

def get(){

  gid=request.form.get('g_id')

  return gid

}

Method Two:

the href = A '' / edit_grade / {{<g_ID>}} ''
Flask front-end routing parameter passing, as this approach does not require intermediate variables, variables directly coupled with the transfer function in the view.

Angle brackets routing variables and view function in the parameter obtained consistent

@app.route('/get/<g_id>',methods=['GET','POST'])

def get(g_id){

  gid=g_id

  return gid

}


Get the value of the background of the front page
, if POST request:
Value method: request.form.get ( 'name')
If GET request:
Value method: request.args.get ( 'name')

Here name is the value of the name attribute of tag

Guess you like

Origin www.cnblogs.com/lnd-blog/p/11584303.html