Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Flask Basics Templates and Static Files Flat HTML

Christopher Stuart
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Christopher Stuart
Full Stack JavaScript Techdegree Graduate 27,771 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?