I have an apache webserver installed on my ubuntu client. The webserver is being accessed by clients from LAN.
I want to have a HTML button, which starts a locally saved phyton script (/etc/skript.py) on my ubuntu client.
I’ve tried different things, but nothing seemed to work.
What’s the easiest way to do it?
Thanks for you help.
I tried this one out:
<button type="button" onclick="/etc/script.py">Click Me!</button>
2
Answers
The value of an
onclick
attribute needs to be the source code for the body of a JavaScript function.Code running in web pages displayed in browsers have no way of executing files on the client.
You can use a link or submit a form to a URL handled by the HTTP server and then make the HTTP server responsible for executing the script. This will run the script on the server, not the client (although they might be the same computer in your case… at least some of the time).
As Quentin mentioned you can create a fastify server or express one, the below example is using fastify
https://glitch.com/edit/#!/kindly-bald-gong
Basically: