Skip to content

Instantly share code, notes, and snippets.

@RobSpectre
Created February 15, 2014 22:56
Show Gist options
  • Save RobSpectre/9026393 to your computer and use it in GitHub Desktop.
Save RobSpectre/9026393 to your computer and use it in GitHub Desktop.
Example serial script with Flask and Twilio
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