-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
34 lines (27 loc) 路 867 Bytes
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from flask import Flask, request
from twilio.twiml.messaging_response import MessagingResponse
from main import TwilioNotification
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
@app.route('/notify', methods=['GET', 'POST'])
def send_notifs():
notif = TwilioNotification().message('Leak is detected')
return str(notif)
@app.route('/sms', methods=['GET', 'POST'])
def sms_reply():
resp = MessagingResponse()
resp.message('Reply is sent')
return str(resp)
def shutdown_server():
func = request.environ.get('werkzeug.server.shutdown')
if func is None:
raise RuntimeError('Not running with the Werkzeug Server')
func()
@app.route('/shutdown', methods=['GET', 'POST'])
def shutdown():
shutdown_server()
return 'Server shutting down...'
if __name__ == '__main__':
app.run(debug=True)