from cgi import parse_qs, escape import smbus import getopt import time bus = smbus.SMBus(1) # For revision 1 Raspberry Pi, change to bus = smbus.SMBus(1) for revision 2. address = 0x22 # I2C address of IO Expander systeme=["system0","system1","system2","system3","system4","system5","system6","system7"] html = """

System, das resetted werden soll
%s
%s
%s
%s
%s
%s
%s
%s

%s

""" def application(environ, start_response): # Get the query string variables d = parse_qs(environ['QUERY_STRING']) output = d.get('output', ['8'])[0] # Escape user input output = int(escape(output)) value=0xff # Shift the bits for the register value, checking if they are already set first if (0 <= output < 8): value -= (1 << output) # now write to the IO expander bus.write_byte_data(address,0,value) time.sleep(1) bus.write_byte_data(address,0,0xff) response_body = html % (systeme[0],systeme[1],systeme[2],systeme[3],systeme[4],systeme[5],systeme[6],systeme[7],"System "+systeme[output]+" wurde zurueckgesetzt") else: response_body = html % (systeme[0],systeme[1],systeme[2],systeme[3],systeme[4],systeme[5],systeme[6],systeme[7],"") # Show the HTML page status = '200 OK' response_headers = [('Content-Type', 'text/html'), ('Content-Length', str(len(response_body)))] start_response(status, response_headers) return [response_body]