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

223
Vistas
Run a python script using requirements with browser JavaScript

My main goal here is to execute a python script I have written when I run a function triggered through HTML. Here is how I have things currently set up:

I have a JavaScript File containing python run functions:

const PythonShell = require('python-shell').PythonShell;
class AHK {
   static async runScript() {
     PythonShell.run('/ahk/script.py', null, function (err) {
       if (err) throw err;
       console.log('finished');
   });
}
module.exports = AHK;

I have my main.js file which would be the js code for the HTML to handle. I'd like for it to take in the module AHK. Something simple like this:

const AHK = require('./ahk');

function runFunction(x){
 if(x = 1)
    AHK.runScript()
 }

And then I have some HTML with a javascript tag

<script type="text/javascript">
let x =1; //this is just to show x is getting populated. In the actual code it's constantly changing values

async function predict() {
  if(x > 1)
    runFunction(x)
}
</script>

Biggest issue I'm facing:

I've become aware that browser javascript doesn't like requirements/modules. For example, the main.js file doesn't like having a requirement at the top. I've tried using things like requirejs, but I can't seem to figure out how to make something like this work. I basically need it so that when the requirement is met and the function runFunction is run, the python script is executed on my machine.

Important to note that this is all running for a personal project on my computer, so it will never not be local.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Make the application on your pc an API and use the web page to send a request to the API telling it which python script to run. I haven't used python too much but I believe you can make an API with it. Then you can just make buttons for each python program you want to run and have these buttons send a request to the API.

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