def get(): """Get top heroes""" try: heroes = Hero.get_top_heroes() heroes_dict = [] for hero in heroes: heroes_dict.append(hero.to_dict()) shuffle(heroes_dict) return {'heroes': heroes_dict[:4]} except Exception as error: return { 'message': 'Error on get top heroes', 'details': str(error) }, 500
def get(self): """Get top heroes""" try: heroes = Hero.get_top_heroes() heroes_dict = [] for hero in heroes: heroes_dict.append(hero.to_dict()) # Falta embaralhar a lista de herois antes de retornar quatro itens random.shuffle(heroes_dict) return {'heroes': heroes_dict[:4]} except Exception as error: return { 'message': 'Error on get top heroes', 'details': str(error) }, 500