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

160
Views
Cómo obtener datos de index.html a matraz en tiempo real

Estoy tratando de obtener datos de websocket a matraz en tiempo real, no encontré la manera de hacerlo, así que intenté hacer una ruta "/" diferente y enviarla nuevamente a otra ruta que es "/ get" pero no funciona porque solo puedo devolver todo el archivo index.html pero solo necesito los datos en tiempo real

 <!doctype html> <html> <head> <title>Flask-Sock Demo</title> </head> <body onload="a()"> <div id="log"></div> <br> <script> const log = (text, color) => { document.getElementById('log').innerHTML += <span style="color: ${color}">${text}</span><br>; }; socket = new WebSocket('ws://' + "localhost:8000"); socket.addEventListener('message', ev => { log( ev.data, 'blue'); saveDynamicDataToFile(ev.data); console.log(ev.data); }); function a(){ console.log("alert!") const textField = "hello" socket.onopen = () => socket.send(textField.value); } </script> </body> </html>
 import asyncio import websockets from flask import Flask, render_template, request from flask_sock import Sock app = Flask(__name__,template_folder='template') sock = Sock(app) @app.route('/') def index(): return render_template("index.html") @app.route('/get', methods=['GET', 'POST']) def get(): return if __name__ == '__main__': app.debug = True app.run(use_reloader=False)
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!