Please help! One small issue with the project, which I enjoyed. I cannot for the life of me figure out what is wrong with my hyperlink for one of the last steps. When I manually type in the path (like ~~ https://localhost/animals/dogs/0 ~~), I get what I want. I don’t understand why this hyperlink is different than the previous code I wrote. The picture is the code that must have something wrong with it, or there is a bug.
@app.route('/animals/<pet_type>')
def animals(pet_type):
html = f'''<h1>List of {pet_type}</h1>'''
for pet_idx, pet in enumerate(pets[pet_type.lower()]):
html = html + '<li><a href="/animals/<pet_type>/<int:pet_idx>">' + pet['name'] + '</a></li>'
return html
@app.route("/animals/<pet_type>/<int:pet_idx>")
def pet(pet_type, pet_idx):
pet = pets[pet_type.lower()][pet_idx]
#petname = pet['name']
return f'''
<h1>{pet['name']}</h1>
<img src={pet['url']} </img>
<p>{pet['description']} </p>
<ul>
<li>{pet['age']}</li>
<li>{pet['breed']}</li>
</ul>
'''