Spaces:
Runtime error
Runtime error
File size: 581 Bytes
f66ca9f c463764 f66ca9f c463764 f66ca9f ad6bc1f f66ca9f c463764 f66ca9f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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() |