Bonjour,
Je débute et découvre le python.
J'aimerai faire une page web très simple pour basculer les relais d'une carte.
Pourquoi avec ce code il ne se passe rien :
Alors qu'avec celui la, ca fonctionne:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 #!/usr/bin/python from subprocess import call, check_output from bottle import route, post, request, run, FlupFCGIServer @route('/') def hello(): return '''<form method="POST" action="/helloworld.py"> <input name="relay_1" value="Relay 1" type="button" onclick="relay();"> </form>''' @post('/') def relay(): out = call (["/usr/sbin/i2cset", "-y", "0", "0x21", "0x00", "0x80"]) run(host='localhost', port=8080, server=FlupFCGIServer)
Quelqu'un pourrait m'éclairer/aider, svp?!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #!/usr/bin/python from subprocess import call, check_output from bottle import route, post, request, run, FlupFCGIServer @route('/') def hello(): return '''<form method="POST" action="/helloworld.py"> <input name="name" type="text" /> <input type="submit" /> </form>''' @post('/') def login_submit(): name = request.forms.get('name') out = call (["/usr/sbin/i2cset", "-y", "0", "0x21", "0x00", name]) run(host='localhost', port=8080, server=FlupFCGIServer)
Partager