Update cemento.py
This commit is contained in:
27
cemento.py
27
cemento.py
@@ -56,27 +56,30 @@ def index():
|
|||||||
def esegui_stampa_cups(f):
|
def esegui_stampa_cups(f):
|
||||||
try:
|
try:
|
||||||
ps_content = f"""%!PS
|
ps_content = f"""%!PS
|
||||||
/Helvetica-Bold findfont 18 scalefont setfont
|
/Helvetica-Bold findfont 16 scalefont setfont
|
||||||
100 750 moveto (REPORT TECNICO CALCOLO CEMENTO) show
|
70 750 moveto (REPORT TECNICO CALCOLO CEMENTO) show
|
||||||
/Helvetica findfont 12 scalefont setfont
|
/Helvetica findfont 11 scalefont setfont
|
||||||
100 720 moveto (Volume: {f.get('res_vol')} m3 | Peso: {f.get('res_peso')} Kg) show
|
70 720 moveto (Volume: {f.get('res_vol')} m3 | Peso: {f.get('res_peso')} Kg) show
|
||||||
100 705 moveto (Costo: {f.get('res_costo_t')} Euro | Acqua: {f.get('res_aq')} L) show
|
70 690 moveto (ACQUISTI:) show
|
||||||
100 680 moveto (ACQUISTI:) show
|
80 675 moveto (- Cemento: {f.get('res_s_cem')} sacchetti) show
|
||||||
120 665 moveto (- Cemento: {f.get('res_s_cem')} | Sabbia: {f.get('res_s_sab')} | Ghiaia: {f.get('res_s_ghi')}) show
|
80 660 moveto (- Sabbia: {f.get('res_s_sab')} sacchetti) show
|
||||||
100 640 moveto (CARICO BETONIERA ({f.get('res_nc')} carichi):) show
|
80 645 moveto (- Ghiaia: {f.get('res_s_ghi')} sacchetti) show
|
||||||
120 625 moveto (- Cemento: {f.get('res_bc_cem')} | Sabbia: {f.get('res_bc_sab')} | Ghiaia: {f.get('res_bc_ghi')}) show
|
70 620 moveto (COSTO TOTALE: {f.get('res_costo_t')} Euro) show
|
||||||
100 550 moveto (Software Cemento Rev.1 | 20/01/2026) show
|
70 590 moveto (DOSAGGIO CARICO ({f.get('res_nc')} carichi):) show
|
||||||
|
80 575 moveto (- Cemento: {f.get('res_bc_cem')} | Sabbia: {f.get('res_bc_sab')}) show
|
||||||
|
80 560 moveto (- Ghiaia: {f.get('res_bc_ghi')} | Acqua: {f.get('res_bc_aq')} L) show
|
||||||
|
70 500 moveto (Software Cemento Rev.1 | 20/01/2026) show
|
||||||
showpage"""
|
showpage"""
|
||||||
comando = ["docker", "exec", "-i", "cups-pdf-server", "lp", "-d", "Virtual_PDF"]
|
comando = ["docker", "exec", "-i", "cups-pdf-server", "lp", "-d", "Virtual_PDF"]
|
||||||
subprocess.run(comando, input=ps_content.encode('utf-8'), capture_output=True)
|
subprocess.run(comando, input=ps_content.encode('utf-8'), capture_output=True)
|
||||||
return "OK - PDF generato correttamente!"
|
return "OK - PDF inviato a CUPS!"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return f"Errore: {str(e)}"
|
return f"Errore: {str(e)}"
|
||||||
|
|
||||||
@app.route('/download', methods=['POST'])
|
@app.route('/download', methods=['POST'])
|
||||||
def download():
|
def download():
|
||||||
f = request.form
|
f = request.form
|
||||||
report = f"REPORT TECNICO\nVolume: {f.get('res_vol')} m3\nCosto: {f.get('res_costo_t')} EUR"
|
report = f"REPORT\nVolume: {f.get('res_vol')} m3\nCosto: {f.get('res_costo_t')} EUR"
|
||||||
return Response(report, mimetype="text/plain", headers={"Content-disposition":"attachment;filename=Report.txt"})
|
return Response(report, mimetype="text/plain", headers={"Content-disposition":"attachment;filename=Report.txt"})
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user