Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

220
Vistas
Insert values from JavaScript to Python to file.xls

I'm trying to insert certain values into a xls or xlsx file, that have been fetched in JavaScript to the python function. How can I insert the values from the JavaScript function into the python function?

This is my python code:

import xlwt
from xlwt import Workbook

    @app.route('/Import_to_excel',
    methods=['GET', 'POST'])
    def Import_to_excel():
    
        x = request.args.get('id0')
        y = request.args.get('id1')
        z = request.args.get('id2')
    
        array = [ ip, app, ver]
        
        wb = Workbook()
        sheet1 = wb.add_sheet('Sheet 1')
    
        sheet1.write(0, 0, array[0])
        sheet1.write(0, 1, array[1])
        sheet1.write(0, 2, array[2])

        wb.save('xlwt example.xls')
        
        return "success"

I have also been trying to post a list with the values, instead of individually posting the values one by one. But i have some problems with request.args.getlist() on the Python side of things.

This is my JavaScript function

function Import_to_excel()
{
    id0 = document.getElementById("x").text
    id1 = document.getElementById("y").value
    id2 = document.getElementById("z").value

    const input_values = [ id0, id1, id2];

 fetch('http://127.0.0.1:5000/Import_to_excel?id0='+id0
 ).then(resp => resp.json())

 fetch('http://127.0.0.1:5000/Import_to_excel?id1='+id1
 ).then(resp => resp.json())

 fetch('http://127.0.0.1:5000/Import_to_excel?id2='+id2
 ).then(resp => resp.json())
}

The output in my xls file is blank.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Python code

id = request.args.get('ID')
x = id.split('_*_')[0]
y = id.split('_*_')[1]
z = id.split('_*_')[2]

JavaScript

  var x = document.getElementById("x").value;
  var y = document.getElementById("y").value;
  var z = document.getElementById("z").value;
  var a = 'http://127.0.0.1:5000/initiate_excel_corvert?ID='x+'_*_'+y+'_*_'+z+'_*_'
           fetch(a)
          .then(res => res.json())
          .then(res => console.log(res));
        }
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda