Z
Z
zyusifov112020-12-12 16:12:21
Flask
zyusifov11, 2020-12-12 16:12:21

How to handle two different ajax requests in one flask function?

when one button is pressed, a request is made with data :

@app.route('/admin', methods=['POST', 'GET'])
def admin_page():
  if request.method == 'POST':
    link = request.form['link']
    industry = request.form['industry']
    
    result = jsonify(parser(link, industry))
    return result
  else:
    return render_template("admin.html")

and for the other:
@app.route('/admin', methods=['POST', 'GET'])
def admin_page():
  if request.method == 'POST':
    data = request.form['data']
  else:
    return render_template("admin.html")


How can I combine all this into one function?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question