Reputation: 325
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
Upvotes: 0
Views: 261
Reputation: 325
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
Upvotes: 1