From fa5da59962c5e08e5e29f02f754e8ee806df0413 Mon Sep 17 00:00:00 2001 From: francesco Date: Mon, 12 Jan 2026 15:53:44 +0100 Subject: [PATCH] Upload files to "/" --- cemento.py | 90 +++++++++++++++++++++++++++++++++++ index.html | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++++ templates | Bin 0 -> 1024 bytes 3 files changed, 227 insertions(+) create mode 100644 cemento.py create mode 100644 index.html create mode 100644 templates diff --git a/cemento.py b/cemento.py new file mode 100644 index 0000000..967f772 --- /dev/null +++ b/cemento.py @@ -0,0 +1,90 @@ +# -*- coding: utf-8 -*- +from flask import Flask, render_template, request, Response +import math + +app = Flask(__name__) + +def calcola(d): + try: + def to_m(v, u): + val = float(v.replace(',', '.')) if v else 0 + return val / 1000 if u == "mm" else val / 100 if u == "cm" else val + + vol = to_m(d.get('a','0'), d.get('ua','m')) * to_m(d.get('l','0'), d.get('ul','m')) * to_m(d.get('p','0'), d.get('up','m')) + peso_tot = vol * 2400 + + mats = ['cem', 'sab', 'ghi'] + p = {m: float(d.get(f'p_{m}', '0').replace(',','.')) for m in mats} + w = {m: float(d.get(f'w_{m}', '25').replace(',','.')) for m in mats} + c = {m: float(d.get(f'c_{m}', '0').replace(',','.')) for m in mats} + + somma_p = sum(p.values()) + res = {"vol": f"{vol:.3f}", "peso": f"{peso_tot:.0f}"} + + tot_s, costo_t = 0, 0 + for m in mats: + kg = (p[m]/somma_p)*peso_tot if somma_p > 0 else 0 + s_esatti = kg/w[m] if w[m] > 0 else 0 + res[f's_{m}'] = math.ceil(s_esatti) + res[f'cost_{m}'] = f"{math.ceil(s_esatti)*c[m]:.2f}" + tot_s += math.ceil(s_esatti) + costo_t += math.ceil(s_esatti)*c[m] + + res.update({"tot_sacc": tot_s, "costo_tot": f"{costo_t:.2f}", "acqua": f"{vol * 150:.0f}"}) + + v_b = float(d.get('v_bet', '160').replace(',','.')) + n_c = max(1, math.ceil((vol*1000)/v_b)) if vol > 0 else 1 + res["n_c"] = n_c + for m in mats: + kg_tot = (p[m]/somma_p)*peso_tot if somma_p > 0 else 0 + res[f'bc_{m}'] = f"{(kg_tot/w[m])/n_c:.2f}" + res["bc_aq"] = f"{(vol*150)/n_c:.2f}" + return res + except: return None + +@app.route('/', methods=['GET', 'POST']) +def index(): + res = None + if request.method == 'POST': res = calcola(request.form) + return render_template('index.html', res=res, form=request.form) + +@app.route('/download', methods=['POST']) +def download(): + # Costruzione del file TXT con tutti i parametri e i risultati + f = request.form + report = f"""------------------------------------------- + REPORT TECNICO CALCOLO CEMENTO +------------------------------------------- + +PARAMETRI DI INPUT: +- Dimensioni: {f.get('a')} {f.get('ua')} (Alt) x {f.get('l')} {f.get('ul')} (Lar) x {f.get('p')} {f.get('up')} (Pro) +- Miscela (Parti): Cem {f.get('p_cem')} | Sab {f.get('p_sab')} | Ghi {f.get('p_ghi')} +- Peso Sacchi: Cem {f.get('w_cem')}kg | Sab {f.get('w_sab')}kg | Ghi {f.get('w_ghi')}kg +- Costo Sacchi: Cem {f.get('c_cem')}€ | Sab {f.get('c_sab')}€ | Ghi {f.get('c_ghi')}€ +- Attrezzatura: Betoniera da {f.get('v_bet')} L + +RISULTATI GENERALI: +- Volume Totale: {f.get('res_vol')} m3 +- Peso Totale: {f.get('res_peso')} Kg +- Acqua Totale: {f.get('res_aq')} L +- Totale Sacchetti da acquistare: {f.get('res_tot_s')} +- COSTO COMPLESSIVO: {f.get('res_costo_t')} € + +DETTAGLIO ACQUISTI: +- Cemento: {f.get('res_s_cem')} sacchetti (€ {f.get('res_c_cem')}) +- Sabbia: {f.get('res_s_sab')} sacchetti (€ {f.get('res_c_sab')}) +- Ghiaia: {f.get('res_s_ghi')} sacchetti (€ {f.get('res_c_ghi')}) + +DOSAGGIO PER SINGOLO CARICO ({f.get('res_nc')} carichi): +- Cemento: {f.get('res_bc_cem')} sacchetti +- Sabbia: {f.get('res_bc_sab')} sacchetti +- Ghiaia: {f.get('res_bc_ghi')} sacchetti +- Acqua: {f.get('res_bc_aq')} L + +------------------------------------------- +Generato da Software Cemento Rev.0 +-------------------------------------------""" + return Response(report, mimetype="text/plain", headers={"Content-disposition":"attachment;filename=Report_Dettagliato.txt"}) + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000) \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..6fbf3f1 --- /dev/null +++ b/index.html @@ -0,0 +1,137 @@ + + + + + + Software Cemento Rev.0 + + + +
+
+
+ + + + + +
Dimensioni
Altezza
Larghezza
Profondità
+ + + + + + + + +
Miscela (Parti)
Cemento:
Sabbia:
Ghiaia:
+ + + + + + + + +
Peso sacchette (Kg)
Cemento:
Kg
Sabbia:
Kg
Ghiaia:
Kg
+ + + + + + + + +
Costo sacchette (€)
Cemento:
Sabbia:
Ghiaia:
+ + + + +
Attrezzatura
Volume Betoniera:
L
+ + +
+
+ +
+

Risultati

+ {% if res %} +
+
+ Volume: {{ res.vol }} m³ | Peso: {{ res.peso }} Kg +
+
+
+

Acquisti

+ Cemento: {{ res.s_cem }} sacchetti
+ Sabbia: {{ res.s_sab }} sacchetti
+ Ghiaia: {{ res.s_ghi }} sacchetti
+ Acqua: {{ res.acqua }} L
+ Totale materiale: {{ res.tot_sacc }} sacchetti +
+
+

Costo stimato

+ Costo totale: {{ res.costo_tot }} € +
+
+
+

Per ogni carico ({{ res.n_c }} carichi):

+ • Cemento: {{ res.bc_cem }} sacchetti
+ • Sabbia: {{ res.bc_sab }} sacchetti
+ • Ghiaia: {{ res.bc_ghi }} sacchetti
+ • Acqua: {{ res.bc_aq }} L +
+
+
+ + + + + + + + + + + + + + + + +
+ + {% else %} +

Inserisci i dati e premi "Esegui Calcolo".

+ {% endif %} +
+
+ + \ No newline at end of file diff --git a/templates b/templates new file mode 100644 index 0000000000000000000000000000000000000000..06d7405020018ddf3cacee90fd4af10487da3d20 GIT binary patch literal 1024 ScmZQz7zLvtFd70QH3R?z00031 literal 0 HcmV?d00001