-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
54 lines (43 loc) · 1.46 KB
/
run.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from flask import Flask, request, redirect
import twilio.twiml
from flask.ext.sqlalchemy import SQLAlchemy
import os
from models import *
app = Flask(__name__)
#app.config.from_object(os.environ['APP_SETTINGS'])
db = SQLAlchemy(app)
# Try adding your own number to this list!
callers = {
"+447763501564": "Jordi",
"+447804654075": "Thomas",
"+447795958759": "Charles",
}
@app.route("/", methods=['GET', 'POST'])
def hello_monkey():
"""Respond and greet the caller by name."""
#NewPart
body_message = str(request.values.get('Body', None))
rocket_name = body_message.split(' ') [0]
motor = body_message.split(' ') [1]
#cursor1 = conn.execute("SELECT VAR1, VAR2 FROM TBL_ROCKETS WHERE ID = " + rocket_name)
#cursor1 = conn.execute("SELECT VAR1, VAR2 FROM TBL_ROCKETS WHERE ID = 1")
results = Result.query.all()
print len(results)
# temp1 = []
#for row in cursor1:
# temp1.append(row)
#cursor2 = conn.execute("SELECT VAR1, VAR2 FROM TBL_MOTORS WHERE ID = " + motor)
#temp2 = []
#for row in cursor2:
# temp2.append(row)
from_number = request.values.get('From', None)
#if from_number in callers:
# message = "Hi! Rocket name: " + rocket_name + " Motor: " + motor + temp1[0]
# else:
message = "Monkey, thanks for the message!"
resp = twilio.twiml.Response()
resp.message(message)
return str(resp)
#return temp1[0]
if __name__ == "__main__":
app.run(debug=True)