def get_pet(request): pet_id = request.match_info['petId'] if pet_id == '5': return web.HTTPNotFound() return web.json_response({ 'id': int(pet_id), 'name': 'Lili', 'photoUrls': [], })