I want when I press a button in cherrypy a specific python script is executed I tried to add it like that but of course that doesn't work, What is the right way to do it
What I want to execute is (ser = serial.Serial('/dev/ttyUSB0')
ser.write(b'hello') )
import cherrypy
import string
class HelloWorld:
""" Sample request handler class. """
@cherrypy.expose
def index(self):
return """<html>
<head></head>
<body>
<form method="get" action="generate">
<button type="submit">Press!</button>
</form>
</body>
ser = serial.Serial('/dev/ttyUSB0')
ser.write(b'hello')
</html>"""
if __name__ == '__main__':
cherrypy.config.update({'server.socket_host': '0.0.0.0'} )
cherrypy.quickstart(HelloWorld())