tomaseo2022 commited on
Commit
08e8516
1 Parent(s): 4789a30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -12,11 +12,11 @@ def convert_zpl_to_pdf(zpl_string):
12
  response = requests.post(labelary_api, headers=headers, data=zpl_string.encode('utf-8'), stream=True)
13
 
14
  if response.status_code == 200:
15
- # Escribimos el contenido PDF en un archivo temporal
16
- with tempfile.NamedTemporaryFile(delete=False, suffix='.pdf') as temp_file:
17
- temp_file.write(response.content)
18
- # Guardamos la ruta del archivo temporal para devolverla
19
- return temp_file.name
20
  else:
21
  raise Exception(f"Error durante la conversi贸n de ZPL a PDF: {response.text}")
22
 
 
12
  response = requests.post(labelary_api, headers=headers, data=zpl_string.encode('utf-8'), stream=True)
13
 
14
  if response.status_code == 200:
15
+ # Creamos un archivo temporal y escribimos el contenido del PDF
16
+ fd, path = tempfile.mkstemp(suffix='.pdf')
17
+ with os.fdopen(fd, 'wb') as tmp:
18
+ tmp.write(response.content)
19
+ return path
20
  else:
21
  raise Exception(f"Error durante la conversi贸n de ZPL a PDF: {response.text}")
22