Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

315
Views
Pasar una variable JS a la URL de la API de Flask

Hice una API usando Flask que tiene una URL de este formato

localhost:5000/data/?query=<Query Goes Here>

Esta API básicamente solo devuelve una página web con este pequeño json:

 { "text" : "(Whatever we entered in the URL)" }

Quería saber cómo podemos pasar una variable Node.js a la URL.

Si no es posible, ¿cómo puedo hacer una API en Python que

Toma la entrada en JS -> La envía a Python para su procesamiento -> Envía la salida de vuelta a JS O Muestra una página renderizada con esa salida

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Te puedo responder con este ejemplo.

Toma entrada en JS :

Archivo JS:

 $("#test_enable").on('click', function(e) { $this = $(this) var test_id = $("#test_id_generator").val(); # get a value from test_id_generator $.ajax({ url: url, type: 'POST', data: { 'test_id': test_id, }, success: function (data) { location.reload(true) } });}

archivo pitón:

 def product_register_disable(request): test_id = request.POST.get('test_id')

Envía la salida de vuelta a JS O Muestra una página renderizada con esa salida

puede mostrar el valor usando JINJA2 y python

lado pitón

 @routes.route('/showtime', methods=["GET", "POST"]) def showtime(): return render_template('showtime.html', value = 'testtest')

lado HTML

 <!DOCTYPE html> <html lang="en"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"> </script> meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <head> <body> <div>{{value}}</div>

espero ayudar

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!