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

231
Views
Django: muestra Httpresponse en la plantilla

Esto es lo que tengo en vistas.

Esta es una función en javascript

Recibo este mensaje cuando ejecuto el proyecto.

Sin embargo, las respuestas se muestran en una página en blanco como esta

¿Cómo hago para que la respuesta https se muestre en la misma página en la ventana de chat y no en una página diferente?

Soy completamente nuevo en Django y javascript. Sería de gran ayuda si alguien puede ayudar. Gracias por adelantado.

Esto es lo que tengo en script.js

 onSendButton(chatbox) { var textField = chatbox.querySelector('input'); let text1 = textField.value if (text1 === "") { return; } let msg1 = { name: "User", message: text1 } this.messages.push(msg1); fetch('http://127.0.0.1:8000/', { method: 'POST', body: JSON.stringify({ message: text1 }), mode: 'cors', headers: { 'Content-Type': 'application/json' }, }) .then(r => r.json()) .then(r => { let msg2 = { name: "Sam", message: r.answer }; this.messages.push(msg2); this.updateChatText(chatbox) textField.value = '' }).catch((error) => { console.error('Error:', error); this.updateChatText(chatbox) textField.value = '' }); }

Esto es lo que tengo en vistas

 def index(request): if request.method == "POST": name = request.POST.get("name", "") response = chatbot_response(name) if response != "": return HttpResponse(response) else: return HttpResponse(response) return render(request, "index.html")

seria muy util si alguien puede ayudar

about 4 years ago · Juan Pablo Isaza
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!