Hello everyone. I am stuck on task 16 on Adopt a Pet project. I have checked previous posts on this issue before and I cant seem to get the answer. Its probably simple and I just need another pair of eyes to find the issue. When I click on the links of the names of the pets I am met with a ‘Not Found’ page.
from flask import Flask
from helper import pets
app = Flask(__name__)
@app.route("/")
def index():
return '''<h1>Adopt a Pet!</h1>
<p>Browse through the links below to find your new furry friend:</p>
<ul>
<li><a href='/animals/dogs'>Dogs</a></li>
<li><a href='/animals/cats'>Cats</a></li>
<li><a href='/animals/rabbits'>Rabbits</a></li>
</ul>
'''
@app.route('/animals/<pet_type>')
def animals(pet_type):
html = f'''<h1>List of {pet_type}</h1>'''
html = html + '<ul>'
for index, pet in enumerate(pets[pet_type]):
name = pet['name']
html += '<li><a href = "/animals/{pet_type}/{index}">' + name + '</a></li>'
html += '</ul>'
return html
@app.route('/animals/<pet_type>/<int:pet_id>')
def pet(pet_type, pet_id):
pet = pets[pet_type][pet_id]
pet_name = pet["name"]
return f'''<h1>{pet_name}</h1>'''```
link to exercise:
https://www.codecademy.com/courses/learn-flask/projects/adopt-a-pet
link to Gist (where my code is):
https://gist.github.com/codecademydev/c61de63f1b99ac1c9b3e11fcd61736eb