You must write local service. But be carefull for security.
- Web Site (HTML)
- Local App Run Program ( exe file: listened on 8001 )
Algorithm
**Example HTML Call **
<button>Run Program</button>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
$("button").click(function(){
$.get("//localhost:8001", function(data, status){
alert("Data: " + data + "\nStatus: " + status);
});
});
</script>
Example App Run Program
# Python 3 server example
from http.server import BaseHTTPRequestHandler, HTTPServer
import time
import subprocess
hostName = "localhost"
serverPort = 8001
class MyServer(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
# IMPORTANT ENABLE HERE CORS
self.send_header("Content-type", "text/html")
self.end_headers()
self.wfile.write(bytes("<ok>Run Start Program</ok>", "utf-8"))
# CHANGE HERE
subprocess.call(['C:\\Temp\\a b c\\Notepad.exe', 'C:\\test.txt'])
if __name__ == "__main__":
webServer = HTTPServer((hostName, serverPort), MyServer)
print("Server started http://%s:%s" % (hostName, serverPort))
try:
webServer.serve_forever()
except KeyboardInterrupt:
pass
webServer.server_close()
print("Server stopped.")