0

Try to pass two parameters but seems like I'm missing something with syntax here , can someone help me on this?

@app.route('/BotMetrics/<int:fromdate>/<int:todate>')
def user(fromdate, todate):
     print("connecting")
     con = Get_hdb()
     cursor1 = con.cursor(pymysql.cursors.DictCursor)
     cursor1.execute("select * from order_details where date between '%s' and '%s'",(fromdate,todate,))
     row = cursor1.fetchall()
     resp = jsonify(row)
     resp.status_code = 200
     return resp

Trying to access URL , here I want to pass two parameters FromDate and ToDate in URL ,

http://127.0.0.1:5000/BotMetrics/?FromDate?Todate

enter image description here

2

1 Answer 1

1

Updated the code to below and it worked

@app.route('/BotMetrics/<fromdate>/<todate>')
def user(fromdate=None, todate=None):
     print("connecting")
     con = Get_hdb()
     cursor1 = con.cursor(pymysql.cursors.DictCursor)
     cursor1.execute("select * from order_details where date between %s and %s",(fromdate,todate,))
     row = cursor1.fetchall()
     resp = jsonify(row)
     resp.status_code = 200
     return resp

URL

http://127.0.0.1:5000/BotMetrics/2021-02-01/2021-02-27
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.