-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
33 lines (24 loc) · 736 Bytes
/
app.py
File metadata and controls
33 lines (24 loc) · 736 Bytes
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
from flask import Flask, request
from twilio.twiml.messaging_response import MessagingResponse
from utils import fetch_reply
app = Flask(__name__)
@app.route("/")
def hello():
return "API Working"
@app.route("/sms", methods=['POST'])
def sms_reply():
"""Respond to incoming calls with a simple text message."""
# Fetch the message
print(request.form)
msg = request.form.get('Body')
sender = request.form.get('From')
# Create reply
resp = MessagingResponse()
result = fetch_reply(msg,sender)
if type(result)==str:
resp.message(result)
else:
resp.message('Here is your photo').media(result[0])
return str(resp)
if __name__ == "__main__":
app.run(debug=True)