Python Flask Basics Welcome to Flask Multiply View

Arshdeep Singh
Arshdeep Singh
6,576 Points

don't understand why this code doesn't work

I wrote the following code and don't understand why it isn't correct.

from flask import Flask

app = Flask(name)

@app.route('/multiply') @app.route('/multiply/num1/num2') def multiply(num1=5, num2=5): return str(num1*num2)

flask_app.py
from flask import Flask

app = Flask(__name__)

@app.route('/multiply')
@app.route('/multiply/num1/num2')
def multiply(num1=5, num2=5):
    return str(num1*num2)

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 65,282 Points

You are really close! you need to include int and the angle brackets: <int:num1> for the app.route.

Post back if you need more help. Good luck!!

Arshdeep Singh
Arshdeep Singh
6,576 Points

Also tried the following but am getting a syntax error:

from flask import Flask

app = Flask(__name__)

@app.route('/multiply')
@app.route('/multiply/num1/num2')

def multiply(<int:num1>=5, <int:num2>=5):
    return str(num1*num2)

[MOD: added ```python formatting -cf]

Chris Freeman
Chris Freeman
Treehouse Moderator 65,282 Points

sorry, I should have been more clear. The <int:num1> goes in the app.route line.