Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

226
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda