Update app.py
Browse files
app.py
CHANGED
@@ -80,6 +80,7 @@ def index():
|
|
80 |
|
81 |
tabela_html = df.to_html(index=False, classes="table table-striped", float_format="R${:,.2f}".format)
|
82 |
|
|
|
83 |
return render_template(
|
84 |
"index.html",
|
85 |
capital=capital,
|
@@ -99,6 +100,7 @@ def index():
|
|
99 |
return render_template("index.html")
|
100 |
|
101 |
|
|
|
102 |
@app.route("/download_pdf", methods=["POST"])
|
103 |
def download_pdf():
|
104 |
# Recebe e converte dados
|
@@ -157,18 +159,12 @@ def download_pdf():
|
|
157 |
grafico_base64 = base64.b64encode(img_buffer.getvalue()).decode('utf-8')
|
158 |
plt.close()
|
159 |
|
160 |
-
tabela
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
}).hide_index().set_table_styles([
|
167 |
-
{'selector': 'th', 'props': [('background-color', '#007bff'), ('color', 'white'), ('text-align', 'center')]},
|
168 |
-
{'selector': 'td', 'props': [('text-align', 'right'), ('padding', '6px 8px')]},
|
169 |
-
{'selector': 'table', 'props': [('border-collapse', 'collapse'), ('width', '100%')]},
|
170 |
-
{'selector': 'th, td', 'props': [('border', '1px solid #000')]},
|
171 |
-
]).render()
|
172 |
|
173 |
html = render_template(
|
174 |
"relatorio_pdf.html",
|
@@ -195,5 +191,6 @@ def download_pdf():
|
|
195 |
return send_file(pdf, mimetype="application/pdf", as_attachment=True, download_name="relatorio_simulacao.pdf")
|
196 |
|
197 |
|
|
|
198 |
if __name__ == '__main__':
|
199 |
app.run(host='0.0.0.0', port=7860, debug=True)
|
|
|
80 |
|
81 |
tabela_html = df.to_html(index=False, classes="table table-striped", float_format="R${:,.2f}".format)
|
82 |
|
83 |
+
|
84 |
return render_template(
|
85 |
"index.html",
|
86 |
capital=capital,
|
|
|
100 |
return render_template("index.html")
|
101 |
|
102 |
|
103 |
+
|
104 |
@app.route("/download_pdf", methods=["POST"])
|
105 |
def download_pdf():
|
106 |
# Recebe e converte dados
|
|
|
159 |
grafico_base64 = base64.b64encode(img_buffer.getvalue()).decode('utf-8')
|
160 |
plt.close()
|
161 |
|
162 |
+
# Formata valores para tabela HTML
|
163 |
+
df_formatado = df.copy()
|
164 |
+
for col in ["Studio", "Franquia", "Ações", "Renda Fixa", "Studio c/ Inflação"]:
|
165 |
+
df_formatado[col] = df_formatado[col].apply(lambda x: f"R$ {x:,.2f}".replace(",", "."))
|
166 |
+
|
167 |
+
tabela = df_formatado.to_html(index=False, classes="table table-striped", border=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
html = render_template(
|
170 |
"relatorio_pdf.html",
|
|
|
191 |
return send_file(pdf, mimetype="application/pdf", as_attachment=True, download_name="relatorio_simulacao.pdf")
|
192 |
|
193 |
|
194 |
+
|
195 |
if __name__ == '__main__':
|
196 |
app.run(host='0.0.0.0', port=7860, debug=True)
|