Update app.py
Browse files
app.py
CHANGED
@@ -8,103 +8,163 @@ from datetime import date, timedelta
|
|
8 |
|
9 |
app = Flask(__name__)
|
10 |
|
11 |
-
# HTML_FORM vem aqui (
|
12 |
-
HTML_FORM = """
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
if __name__ == "__main__":
|
110 |
app.run(host="0.0.0.0", port=7860)
|
|
|
8 |
|
9 |
app = Flask(__name__)
|
10 |
|
11 |
+
# HTML_FORM vem aqui (atualizado com estilo moderno)
|
12 |
+
HTML_FORM = """
|
13 |
+
<!DOCTYPE html>
|
14 |
+
<html>
|
15 |
+
<head>
|
16 |
+
<title>Orçamento de Reforma</title>
|
17 |
+
<style>
|
18 |
+
body {
|
19 |
+
font-family: 'Segoe UI', sans-serif;
|
20 |
+
background-color: #f4f6f8;
|
21 |
+
margin: 0;
|
22 |
+
padding: 2rem;
|
23 |
+
}
|
24 |
+
h2, h3 {
|
25 |
+
color: #333;
|
26 |
+
}
|
27 |
+
form {
|
28 |
+
background: #fff;
|
29 |
+
padding: 2rem;
|
30 |
+
border-radius: 12px;
|
31 |
+
box-shadow: 0 0 12px rgba(0,0,0,0.05);
|
32 |
+
max-width: 700px;
|
33 |
+
margin: auto;
|
34 |
+
}
|
35 |
+
label {
|
36 |
+
display: block;
|
37 |
+
margin-top: 1rem;
|
38 |
+
font-weight: bold;
|
39 |
+
}
|
40 |
+
input[type="text"],
|
41 |
+
input[type="number"],
|
42 |
+
select {
|
43 |
+
width: 100%;
|
44 |
+
padding: 0.5rem;
|
45 |
+
margin-top: 0.3rem;
|
46 |
+
border: 1px solid #ccc;
|
47 |
+
border-radius: 8px;
|
48 |
+
}
|
49 |
+
button {
|
50 |
+
background-color: #007bff;
|
51 |
+
color: white;
|
52 |
+
padding: 0.75rem 1.5rem;
|
53 |
+
border: none;
|
54 |
+
border-radius: 8px;
|
55 |
+
cursor: pointer;
|
56 |
+
margin-top: 1rem;
|
57 |
+
margin-right: 1rem;
|
58 |
+
}
|
59 |
+
button:hover {
|
60 |
+
background-color: #0056b3;
|
61 |
+
}
|
62 |
+
.checkbox-group {
|
63 |
+
display: grid;
|
64 |
+
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
65 |
+
gap: 0.5rem;
|
66 |
+
margin-top: 1rem;
|
67 |
+
}
|
68 |
+
.checkbox-group label {
|
69 |
+
font-weight: normal;
|
70 |
+
}
|
71 |
+
#banheiros-container h4 {
|
72 |
+
margin-top: 1rem;
|
73 |
+
}
|
74 |
+
ul {
|
75 |
+
background: #fff;
|
76 |
+
max-width: 700px;
|
77 |
+
margin: 2rem auto;
|
78 |
+
padding: 1rem;
|
79 |
+
border-radius: 12px;
|
80 |
+
box-shadow: 0 0 12px rgba(0,0,0,0.05);
|
81 |
+
}
|
82 |
+
</style>
|
83 |
+
</head>
|
84 |
+
<body>
|
85 |
+
<h2 style="text-align:center;">Formulário de Orçamento de Reforma</h2>
|
86 |
+
<form method="post">
|
87 |
+
<label>Nome do Contratante:</label>
|
88 |
+
<input type="text" name="nome_contratante" required>
|
89 |
+
|
90 |
+
<label>Endereço da Obra:</label>
|
91 |
+
<input type="text" name="endereco_obra" required>
|
92 |
+
|
93 |
+
<label>Dimensão da obra (m²):</label>
|
94 |
+
<input type="number" step="0.1" name="dimensao_obra" required>
|
95 |
+
|
96 |
+
<h3>Cozinha</h3>
|
97 |
+
<label>Tamanho:</label>
|
98 |
+
<select name="cozinha_tamanho">
|
99 |
+
<option value="pequeno">Pequeno</option>
|
100 |
+
<option value="medio">Médio</option>
|
101 |
+
<option value="grande">Grande</option>
|
102 |
+
</select>
|
103 |
+
<label>Acabamento:</label>
|
104 |
+
<select name="cozinha_acabamento">
|
105 |
+
<option value="simples">Simples</option>
|
106 |
+
<option value="medio">Médio</option>
|
107 |
+
<option value="luxo">Luxo</option>
|
108 |
+
</select>
|
109 |
+
|
110 |
+
<h3>Banheiros</h3>
|
111 |
+
<label>Quantidade:</label>
|
112 |
+
<input type="number" name="banheiros" min="0" max="5" value="1" required>
|
113 |
+
<div id="banheiros-container"></div>
|
114 |
+
|
115 |
+
<h3>Serviços</h3>
|
116 |
+
<div class="checkbox-group">
|
117 |
+
<label><input type="checkbox" name="servicos" value="hidraulica"> Hidráulica</label>
|
118 |
+
<label><input type="checkbox" name="servicos" value="eletrica"> Elétrica</label>
|
119 |
+
<label><input type="checkbox" name="servicos" value="pintura"> Pintura</label>
|
120 |
+
<label><input type="checkbox" name="servicos" value="ar_condicionado"> Ar Condicionado</label>
|
121 |
+
<label><input type="checkbox" name="servicos" value="fechamento_sacada"> Fechamento de Sacada</label>
|
122 |
+
<label><input type="checkbox" name="servicos" value="gesso"> Gesso</label>
|
123 |
+
</div>
|
124 |
+
|
125 |
+
<button type="submit" name="acao" value="Calcular Orçamento">Calcular Orçamento</button>
|
126 |
+
<button type="submit" name="acao" value="Gerar Contrato PDF">Gerar Contrato PDF</button>
|
127 |
+
</form>
|
128 |
+
|
129 |
+
{% if total %}
|
130 |
+
<ul>
|
131 |
+
<h3>Resumo do Orçamento</h3>
|
132 |
+
{% for item in detalhes %}
|
133 |
+
<li>{{ item }}</li>
|
134 |
+
{% endfor %}
|
135 |
+
<p><strong>Total: R$ {{ total }}</strong></p>
|
136 |
+
</ul>
|
137 |
+
{% endif %}
|
138 |
+
|
139 |
+
<script>
|
140 |
+
function gerarBanheiros() {
|
141 |
+
const container = document.getElementById("banheiros-container");
|
142 |
+
const qtd = parseInt(document.querySelector("input[name='banheiros']").value);
|
143 |
+
container.innerHTML = "";
|
144 |
+
for (let i = 1; i <= qtd; i++) {
|
145 |
+
container.innerHTML += `
|
146 |
+
<h4>Banheiro ${i}</h4>
|
147 |
+
<label>Tamanho:</label>
|
148 |
+
<select name="banheiro_${i}_tamanho">
|
149 |
+
<option value="pequeno">Pequeno</option>
|
150 |
+
<option value="medio">Médio</option>
|
151 |
+
<option value="grande">Grande</option>
|
152 |
+
</select>
|
153 |
+
<label>Acabamento:</label>
|
154 |
+
<select name="banheiro_${i}_acabamento">
|
155 |
+
<option value="simples">Simples</option>
|
156 |
+
<option value="medio">Médio</option>
|
157 |
+
<option value="luxo">Luxo</option>
|
158 |
+
</select>
|
159 |
+
`;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
window.onload = gerarBanheiros;
|
163 |
+
document.querySelector("input[name='banheiros']").addEventListener("input", gerarBanheiros);
|
164 |
+
</script>
|
165 |
+
</body>
|
166 |
+
</html>
|
167 |
+
"""
|
168 |
|
169 |
if __name__ == "__main__":
|
170 |
app.run(host="0.0.0.0", port=7860)
|