You can search around for other options since there are a lot of ways to do something like this, but something similar to this could work:
Run at location of script.py
:
import subprocess
import SocketServer
from BaseHTTPServer import BaseHTTPRequestHandler
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
subprocess.call('python script.py', shell=True)
self.send_response(200)
server = SocketServer.TCPServer(("", 8080), RequestHandler)
server.serve_forever()
Run within Farmware:
import requests
requests.get('http://localhost:8080')
This would run script.py
on the http server. localhost
should be replaced with the IP address of the server (for example, 192.168.1.100
).