Instantly share code, notes, and snippets.

@bassdread /app.py
Last active Aug 29, 2015

Embed
What would you like to do?
Simple Flask App
from flask import Flask
import serial
from datetime import datetime, timedelta
from time import sleep
serial_port = '/dev/tty.usbserial-A501S1GX' # most likely you will need to change this!
ser = serial.Serial(serial_port, 9600)
sleep(1.5)
app = Flask(__name__)
@app.route("/input/<colour>/<movement>")
def input(colour, movement):
ser.write('0,{0},{1}\n' .format(colour, movement))
return "Done!"
@app.route("/output/<colour>/<movement>")
def output(colour, movement):
ser.write('1,{0},{1}\n' .format(colour, movement))
return "Done!"
if __name__ == "__main__":
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment