import streamlit as st from datetime import date import locale import os # Corrigir locale para português (Windows) try: locale.setlocale(locale.LC_TIME, "Portuguese_Brazil.1252") except: pass # Mapear os modelos HTML disponíveis html_template_paths = { "Clean": "modelo_proposta_clean.html", "Topo Moderno": "modelo_proposta_topo_moderno.html", "Topo Gradiente": "modelo_proposta_topo_gradiente.html" } st.set_page_config(page_title="Gerador de Propostas", layout="centered") st.title("📝 Gerador de Propostas - EasyDevBots") # Formulário de preenchimento nome_cliente = st.text_input("Nome do Cliente") data_proposta = st.date_input("Data da Proposta", value=date.today()).strftime("%d de %B de %Y") nome_projeto = st.text_input("Nome do Projeto") objetivo = st.text_area("Objetivo da Proposta") valor = st.text_input("Valor Total (R$)") pagamento = st.text_input("Forma de Pagamento") prazo_entrega = st.text_input("Prazo de Entrega") observacoes = st.text_area("Observações / Bônus") validade_proposta = st.text_input("Validade da Proposta", value="15 dias") # Escolher layout visual modelo = st.selectbox("Escolha o modelo visual da proposta:", ["Clean", "Topo Moderno", "Topo Gradiente"]) # Botão de geração if st.button("📄 Gerar Proposta"): modelo_path = html_template_paths[modelo] if not os.path.exists(modelo_path): st.error(f"Modelo HTML não encontrado: {modelo_path}") else: # Ler modelo e substituir campos with open(modelo_path, "r", encoding="utf-8") as f: html = f.read() contexto = { "{{nome_cliente}}": nome_cliente, "{{data_proposta}}": data_proposta, "{{nome_projeto}}": nome_projeto, "{{objetivo}}": objetivo, "{{valor}}": valor, "{{pagamento}}": pagamento, "{{prazo_entrega}}": prazo_entrega, "{{observacoes}}": observacoes, "{{validade_proposta}}": validade_proposta } for chave, valor in contexto.items(): html = html.replace(chave, valor) nome_arquivo = f"Proposta_{nome_cliente.replace(' ', '_')}.html" with open(nome_arquivo, "w", encoding="utf-8") as f: f.write(html) st.success("✅ Proposta gerada com sucesso!") with open(nome_arquivo, "rb") as file: st.download_button("📥 Baixar Proposta HTML", file, file_name=nome_arquivo)