Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // server.py
- def leds_set(state):
- import paramiko
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- ssh.connect('127.0.0.1', username='ahah', password='lol')
- if state:
- state = 'on'
- else:
- state = 'off'
- stdin, stdout, stderr = ssh.exec_command('python /home/ahah/ledson.py ' + state)
- print(stdin, stdout, stderr)
- return dict()
- // view.html
- {{extend 'layout.html'}}
- <form>
- <input type="button" onclick="leds_set(True);" value="leds on"/>
- <input type="button" onclick="leds_set(False);" value="leds off"/>
- </form>
- // ledson.py
- state = sys.argv[1]
- if state =='on':
- print('Leds ON')
- else:
- print('Leds OFF')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement