Commits

Ben Bass committed d6697f0

fix bit_server by using checked status

Comments (0)

Files changed (1)

pylibftdi/examples/bit_server.py

         page += """
 <fieldset style="background-color: %s; display: inline-block; margin:0px; padding: 8px;">
 <form action="" method="post" >
-<input type="checkbox" onchange="document.querySelector('[name=bit%d]').value=this.value; document.forms[%d].submit()" %s />
+<input type="checkbox" onchange="document.querySelector('[name=bit%d]').value=this.checked; document.forms[%d].submit()" %s />
 <input type="hidden" name="bit%d" />
 </form>
 </fieldset>
         query = self.rfile.read(nbytes)
         # this is lazy and fragile - assumes only a single
         # query parameter XXX
+        print query
         if query.startswith('bit'):
             bit = int(query[3])
-            value = 1 if query.rsplit('=', 1)[-1] == 'on' else 0
+            value = 1 if query.rsplit('=', 1)[-1] == 'true' else 0
             if value:
                 switch.port |= (1 << bit)
             else: