Python Flask Basics Templates and Static Files Flat HTML

Christopher Stuart
Christopher Stuart
Full Stack JavaScript Techdegree Graduate 27,736 Points

Can't pass add.html template

for some reason when i preview this it is still printing "Hello from Treehouse" and not passing the add.html template. Any help?

from flask import Flask
from flask import render_template

app = Flask(__name__)

@app.route('/')
@app.route('/<name>')
def index(name="Treehouse"):
    return "Hello from {}".format(name)

@app.route('/add/<int:num1>/<int:num2>')
@app.route('/add/<float:num1>/<float:num2>')
@app.route('/add/<int:num1>/<float:num2>')
@app.route('/add/<float:num1>/<int:num2>')
def add(num1,num2):
    context = {'num1':num1, 'num2': num2}
    return render_template("add.html")

app.run(debug=True,port=8000,host='0.0.0.0')



Ryan Oakes
Ryan Oakes
9,787 Points

Are you actually changing your URL in the browser? They're two separate views, so you will need to go to something like "/add/3/4" to actually see the change.

If you are going to the new URL and it's not loading the view what error message are you getting?