Created
February 15, 2014 22:56
-
-
Save RobSpectre/9026393 to your computer and use it in GitHub Desktop.
Example serial script with Flask and Twilio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from flask import request | |
from twilio import twiml | |
import serial | |
# Declare and configure application | |
app = Flask(__name__, static_url_path='/static') | |
@app.route('/sms', methods=['POST']) | |
def sms(): | |
body = request.form['Body'] | |
ser = serial.Serial('/dev/usb/hiddev0', 9600) | |
ser.write(body) | |
response = twiml.Response() | |
response.message("I sent this to the serial connection: %s" % body) | |
return str(response) | |
if __name__ == "__main__": | |
port = 5000 | |
app.debug = True | |
app.run(host="0.0.0.0", port=port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment