Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. from flask import Flask, send_from_directory
  2. import serial
  3. app = Flask(__name__, static_url_path='')
  4. ser = serial.Serial('/dev/tty.usbmodem1421')
  5. print(ser)
  6.  
  7. @app.route('/start')
  8. def start():
  9.     return send_from_directory('','start.html')
  10.  
  11. @app.route('/on')
  12. def on():
  13.     ser.write('r.turnOff();\n')
  14.     return 'on'
  15.  
  16. @app.route('/off')
  17. def off():
  18.     ser.write('r.turnOn();\n')
  19.     return 'off'
  20.  
  21. if __name__ == '__main__':
  22.     app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement