app.py
def hello_sms():
    """Handle incoming Twilio message routing."""
    if not request or not request.form \
            or not request.form['Body'] or request.form['Body'] == '':
        # Some error, check your Webhook.
        resp = MessagingResponse().message(
            "Unknown error or empty.  Check Twilio's console and debugger."
        )
        return str(resp)

    # Happy cases!
    morse_body = request.form['Body'].lower()
    if len(request.form['Body']) > 63:
        # We're only going to take the first 63 characters, warn them.
        resp = MessagingResponse().message(
            "We can only handle 63 maximum characters.  "
            "Message truncated."
        )
        morse_body = morse_body[0:63]
        print(morse_body)
    else:
        # Awesome!  Full Morse code coming up.
        resp = MessagingResponse().message(
            "We'll make it - ahem, blink it - so!"
        )

    r = requests.post(
        'https://api.particle.io/v1/devices/' + DEVICE_NAME +
        '/' + FUNCTION_NAME,
        data={
            'access_token': PARTICLE_TOKEN,
            'arg': morse_body
        }
    )

    print(r.url)
    print(r.text)

    return str(resp)
Handle incoming Twilio message routing.
Handle incoming Twilio message routing.
Handle incoming Twilio message routing .
def hello_sms():
    if not request or not request.form \
            or not request.form['Body'] or request.form['Body'] == '':
        resp = MessagingResponse().message(
            "Unknown error or empty.  Check Twilio's console and debugger."
        )
        return str(resp)
    morse_body = request.form['Body'].lower()
    if len(request.form['Body']) > 63:
        resp = MessagingResponse().message(
            "We can only handle 63 maximum characters.  "
            "Message truncated."
        )
        morse_body = morse_body[0:63]
        print(morse_body)
    else:
        resp = MessagingResponse().message(
            "We'll make it - ahem, blink it - so!"
        )
    r = requests.post(
        'https://api.particle.io/v1/devices/' + DEVICE_NAME +
        '/' + FUNCTION_NAME,
        data={
            'access_token': PARTICLE_TOKEN,
            'arg': morse_body
        }
    )
    print(r.url)
    print(r.text)
    return str(resp)
def hello_sms ( ) : if not request or not request . form or not request . form [ 'Body' ] or request . form [ 'Body' ] == '' : resp = MessagingResponse ( ) . message ( "Unknown error or empty.  Check Twilio's console and debugger." ) return str ( resp ) morse_body = request . form [ 'Body' ] . lower ( ) if len ( request . form [ 'Body' ] ) > 63 : resp = MessagingResponse ( ) . message ( "We can only handle 63 maximum characters.  " "Message truncated." ) morse_body = morse_body [ 0 : 63 ] print ( morse_body ) else : resp = MessagingResponse ( ) . message ( "We'll make it - ahem, blink it - so!" ) r = requests . post ( 'https://api.particle.io/v1/devices/' + DEVICE_NAME + '/' + FUNCTION_NAME , data = { 'access_token' : PARTICLE_TOKEN , 'arg' : morse_body } ) print ( r . url ) print ( r . text ) return str ( resp )
Handle incoming Twilio message routing.
Handle incoming Twilio message routing .
"""Handle incoming Twilio message routing.""" # Some error, check your Webhook. # Happy cases! # We're only going to take the first 63 characters, warn them. # Awesome!  Full Morse code coming up.