Boa tarde de novo, mesmo que agora o api/restaurantes/ esteja funcionando ele esta dando esta mensagem:
{"Restaurante":null,"Cardapio":{}}
como posso corrigir?
from fastapi import FastAPI, Query
import requests
app = FastAPI()
@app.get('/api/hello')
def hello_world():
return {'Hello':'Wolrd'}
@app.get('/api/restaurantes/')
def get_restaurantes(restaurante: str = Query(None)):
url = 'https://guilhermeonrails.github.io/api-restaurantes/restaurantes.json'
response = requests.get(url)
print(response)
if response.status_code == 200:
dados_json = response.json()
dados_restaurante = {}
for item in dados_json:
if item['Company'] == restaurante:
dados_restaurante.append({
"item": item['Item'],
"price": item['price'],
"description": item['description']
})
return {'Restaurante':restaurante,'Cardapio':dados_restaurante}
else:
print(f'Erro: {response.status_code} - {response.text}')