Created
August 28, 2013 23:20
-
-
Save dansku/6372602 to your computer and use it in GitHub Desktop.
Send message via Python Flask
This file contains 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
import time | |
import pygsm | |
from flask import Flask | |
app = Flask(__name__) | |
app.config['DEBUG'] = False | |
@app.route('/') | |
def hello_world(): | |
return 'Hey bitch!' | |
@app.route('/send/<numero>/<mensagem>') | |
def picname(numero, mensagem): | |
if numero[1:].isdigit(): | |
time.sleep(5) #ESPERA 5 SEGUNDOS | |
modem = pygsm.GsmModem(port='/dev/ttyUSB1', baudrate=19200, timeout=5).boot() | |
modem.send_sms(numero, mensagem) | |
return 'Mensagem: ' + mensagem + ' - enviada para: ' + numero | |
else: | |
return 'entre com um numero, seu cabra da peste!' | |
@app.errorhandler(500) | |
def internal_error(error): | |
return "ERRO 500, bitch! Deu merda, tenta de novo! " | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment