Reputation: 171
I want to take 'age' as an input from user, and also the gender. Now I want to check that whether two things:
age>18 and gender=Male
I used the following routing in my flask code.
@app.route('/checkAge', methods=['GET'])
def foo():
age= request.args.get('age')
gender = request.args.get('gender')
if(gender=='Male'&&age>18):
print age-5
the url that I used to access the route:
/createcm?gender=Male&age=20
Still I am getting some Internal server error. Please help me out that how to process values taken from the get parameters in flask.
Upvotes: 0
Views: 704
Reputation: 113948
if(gender=='Male'&&age>18):
is not python
try
if(gender=='Male' and age>18):
additionally you should set your app.debug=True
which would have told you this
you should also probably be casting age to an int before trying to compare it
if(gender=='Male' and int(age)>18):
return "You are an adult male!"
to answer your other totally unrelated question that you posted in the comments
@app.route('/createcm', methods=['GET'])
def foo():
return str(request.args.get("age",type=int) + request.args.get("weight",type=int))
Upvotes: 1