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

237
Views
Cómo crear una terminal en el navegador similar a replit.com

Estoy tratando de crear una terminal que pueda usar en un navegador para ejecutar programas, similar a replit.com , donde puede ejecutar código en el navegador e interactuar con el programa. Hasta ahora he creado un cliente JS y un servidor Python. El cliente JS se ve así:

 var server = new WebSocket("ws://localhost:8001"); $(document).ready(function () { $("input").on("keydown", function search(e) { if (e.keyCode == 13) { server.send($(this).val()); } }); server.onmessage = function (event) { $("#result").append(event.data.replaceAll("\n", "<br>") + "<br>"); }; });

Que se conecta al servidor, envía todos los comandos y recibe todos los resultados.

El servidor se ve así:

 #!/usr/bin/env python import asyncio import websockets import subprocess async def handler(websocket, _): while True: message = await websocket.recv() message = message.split() try: output = subprocess.run( [*message], stdout=subprocess.PIPE).stdout.decode('utf-8') await websocket.send(output) except: await websocket.send("Command error") async def main(): async with websockets.serve(handler, "", 8001): await asyncio.Future() asyncio.run(main())

Esto funciona para ejecutar comandos únicos, pero no si quiero ejecutar un programa de Python e interactuar con él. ¿Hay alguna forma de que yo haga eso?

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!