Advertisement
Guest User

Untitled

a guest
Jun 7th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. // server.py
  2.  
  3. def leds_set(state):
  4. import paramiko
  5. ssh = paramiko.SSHClient()
  6. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  7. ssh.connect('127.0.0.1', username='ahah', password='lol')
  8. if state:
  9. state = 'on'
  10. else:
  11. state = 'off'
  12. stdin, stdout, stderr = ssh.exec_command('python /home/ahah/ledson.py ' + state)
  13. print(stdin, stdout, stderr)
  14. return dict()
  15.  
  16. // view.html
  17. {{extend 'layout.html'}}
  18.  
  19. <form>
  20. <input type="button" onclick="leds_set(True);" value="leds on"/>
  21. <input type="button" onclick="leds_set(False);" value="leds off"/>
  22. </form>
  23.  
  24. // ledson.py
  25.  
  26. state = sys.argv[1]
  27.  
  28. if state =='on':
  29. print('Leds ON')
  30. else:
  31. print('Leds OFF')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement