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

166
Visualizações
Making web server run scripts

I'm sure a 100 people asked this before but I couldn't find the right key words to google it.

Simply put: How do I make a web client send information to the web server the right way?

I have a simple website set up with apache 2 on a raspberry with ubuntu. Something very basic. I'd like to have a button on my website that makes my server run a script (I wrote that script in c++ but I don't care if I have to translate it). One solution is using JS client-side to send a message to my server on a specific port (say 50000), and having the server listen on that port with a custom listener.

That works fine, but I'm sure there is a right way to do this. How should I do this so that people won't be pissed by my architecture too much? (+using other ports than 80 and 443 on browser may not work if the client blocks other ports)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

What you want to do is create a RESTful web API. The server can listen on a specific port and handle different HTTP requests in different ways. You will want to use Controllers, Services, and potentially a Data Access Object layer. You could either have the script you want to run in code, or you could have your code simply make a call to execute a bash or shell script once you get a valid request of the correct type (GET, POST, PATCH, PUT, etc) with the correct parameters.

https://www.tutorialspoint.com/nodejs/nodejs_restful_api.htm

You're correct, it would be a bad decision to try to have a single endpoint on one port do one thing, and another endpoint on another port do something else. First, a single application can only listen on a single port (or at least should only listen on a single port), so you'd need to spin up a new application for everything you want your back-end server to do. Second, you can't be semantic. Your users would have to look at a dictionary of port - action mappings, instead of being able to (for example) send a request to yourService.com/run/script/1234 to run a script with ID of 1234.

Here is a bit of information on HTTP requests to get you started: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods

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