Update app.py
Browse files
app.py
CHANGED
@@ -66,46 +66,32 @@ def gerar_pdf_arquivo(valor_imovel, investimento_proprio, aluguel_mensal, tempo_
|
|
66 |
|
67 |
return pdf_path
|
68 |
|
69 |
-
# Interface Gradio
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
pdf_button = gr.Button("Gerar PDF", variant="primary")
|
93 |
-
|
94 |
-
# Função de callback para o botão Gerar PDF
|
95 |
-
def on_pdf_button_click(valor_imovel, investimento_proprio, aluguel_mensal, tempo_anos, taxa_juros):
|
96 |
-
# Gerar PDF
|
97 |
-
return gerar_pdf_arquivo(valor_imovel, investimento_proprio, aluguel_mensal, tempo_anos, taxa_juros)
|
98 |
-
|
99 |
-
# Associando a função ao botão Gerar PDF
|
100 |
-
pdf_button.click(on_pdf_button_click, inputs=[
|
101 |
-
gr.Number(label="Valor do Imóvel (R$)", value=500000),
|
102 |
-
gr.Number(label="Investimento Próprio (R$)", value=100000),
|
103 |
-
gr.Number(label="Aluguel Mensal (R$)", value=2500),
|
104 |
-
gr.Number(label="Tempo (anos)", value=20),
|
105 |
-
gr.Number(label="Taxa de Juros (%)", value=8)
|
106 |
-
], outputs=[gr.File(label="Baixar PDF")])
|
107 |
|
108 |
# Rodar a interface Gradio
|
109 |
iface.launch(share=True)
|
110 |
|
111 |
|
|
|
|
66 |
|
67 |
return pdf_path
|
68 |
|
69 |
+
# Interface Gradio com gr.Blocks
|
70 |
+
with gr.Blocks() as iface:
|
71 |
+
# Inputs para os dados
|
72 |
+
valor_imovel = gr.Number(label="Valor do Imóvel (R$)", value=500000)
|
73 |
+
investimento_proprio = gr.Number(label="Investimento Próprio (R$)", value=100000)
|
74 |
+
aluguel_mensal = gr.Number(label="Aluguel Mensal (R$)", value=2500)
|
75 |
+
tempo_anos = gr.Number(label="Tempo (anos)", value=20)
|
76 |
+
taxa_juros = gr.Number(label="Taxa de Juros (%)", value=8)
|
77 |
+
|
78 |
+
# Resultado do cálculo ROI
|
79 |
+
roi_resultado = gr.Textbox(label="Resultado do Cálculo do ROI", lines=3)
|
80 |
+
|
81 |
+
# Botão Gerar ROI
|
82 |
+
gerar_roi_button = gr.Button("Gerar ROI")
|
83 |
+
gerar_pdf_button = gr.Button("Gerar PDF")
|
84 |
+
|
85 |
+
# Funções de callback para os botões
|
86 |
+
gerar_roi_button.click(fn=calcular_gerar_roi, inputs=[valor_imovel, investimento_proprio, aluguel_mensal, tempo_anos, taxa_juros], outputs=roi_resultado)
|
87 |
+
gerar_pdf_button.click(fn=gerar_pdf_arquivo, inputs=[valor_imovel, investimento_proprio, aluguel_mensal, tempo_anos, taxa_juros], outputs=gr.File(label="Baixar PDF"))
|
88 |
+
|
89 |
+
# Configuração do tema e título
|
90 |
+
iface.title = "Cálculo de ROI de Aluguel"
|
91 |
+
iface.description = "Insira os valores abaixo e calcule o retorno sobre investimento (ROI) de aluguel."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
# Rodar a interface Gradio
|
94 |
iface.launch(share=True)
|
95 |
|
96 |
|
97 |
+
|