import requests import gradio as gr def conversao_moeda(valor, moeda_origem, moeda_destino): url = "https://api.ecb.europa.eu/exchange/1.0/latest/{}/{}".format(moeda_origem, moeda_destino) resposta = requests.get(url) taxa = resposta.json()["rates"]["EUR"] valor_convertido = valor * taxa return {"Valor Convertido": valor_convertido} interface = gr.Interface( fn=conversao_moeda, inputs=[gr.Number(value=1.0), gr.Dropdown(["USD", "GBP", "EUR"], type="value"), gr.Dropdown(["USD", "GBP", "EUR"], type="value")] outputs="json" ) interface.launch()