My Adopt a Pet solution

Hello this is my code solution for the project, hope this use it or is helpfull for other people :grinning:

from flask import Flask 
from helper import pets

app = Flask(__name__)

def index():
  return f'''
  <h1>Adopt a Pet!</h1>
  <p>Browse through the links below to 
  find your new furry friend:</p>
    <li><a href='/animals/dogs'>Dogs</a></li>
    <li><a href='/animals/cats'>Cats</a></li>
    <li><a href='/animals/rabbits'>Rabbits</a></li>

def animals(pet_type):
  pet_list_html = ""
  for idx, item in enumerate(pets[pet_type]):
    pet_list_html += f'''<li><a href = '/animals/{pet_type}/{idx}'>{item['name']}</a></li>'''
  html = f'''
    <h1>List of {pet_type}</h1>
  return html

def pet(pet_type, pet_id):
  pet = pets[pet_type][pet_id]
  html = f'''
    <img src="{pet["url"]}" />
  return html

Yes, Thank you. I understand now. :grinning:

1 Like