-
Notifications
You must be signed in to change notification settings - Fork 1
/
pizza.py
161 lines (146 loc) · 5.27 KB
/
pizza.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
from flask import Flask, request, jsonify
import Mysqlconnector as connect
import GenerateResponse as res
import Error as err
app= Flask(__name__)
@app.route('/webhook', methods=['POST'])
@cross_origin()
def webhook():
req = request.get_json(silent=True, force=True)
res = processRequest(req)
res = json.dumps(res, indent=4)
print(res)
r = make_response(res)
r.headers['Content-Type'] = 'application/json'
return r
@app.route("/fetch", methods=["get", "post"])
def fetch():
conn = connect.ConnectMySql()
print(f"Connection status : {conn}")
if(conn is False):
return err.ReturnConnectionError()
else:
try:
cur = conn.cursor()
print(f"Cursor object : {cur}")
query = ("select * from pizza")
cur.execute(query)
msg = "Data fetched succesfully"
return res.GenerateResponse(cur,msg)
except Exception as e:
print(e)
return err.ReturnFetchError()
finally:
conn.close()
@app.route("/fetch1", methods=["get", "post"])
def fetch():
conn = connect.ConnectMySql()
print(f"Connection status : {conn}")
if(conn is False):
return err.ReturnConnectionError()
else:
try:
cur = conn.cursor()
print(f"Cursor object : {cur}")
query = ("select * from customer")
cur.execute(query)
msg = "Data fetched succesfully"
return res.GenerateResponse(cur,msg)
except Exception as e:
print(e)
return err.ReturnFetchError()
finally:
conn.close()
@app.route("/insert", methods=["post"])
def insertdata():
data=reponse.json
pass
if intent == 'Welcome':
{ "fulfillmentMessages": [
{
"text": {
"text": [
webhookresponse
]
}
},
{
"text":
{
"text": [
"Hello :) Welcome to YoYo Pizza , Hope you are staying at home safe! What can I do for you?"
]
}
]
}
}
elif intent == 'Order':
{ "fulfillmentMessages": [
{
"text": {
"text": [
webhookresponse
]
}
}
{
"text":
{
"text": [
"Please select what kind of pizza do you want? veg or nonveg"
]
}
]
}
}
elif intent == 'Order':
{"fulfillmentMessages": [
{
"text": {
"text": [
webhookresponse
]
}
}
{
"text":
{
"text": [
"Please select what kind of pizza do you want? veg or nonveg"
]
}
]
}
}
elif intent == "Veg":
fulfillmentText = result.get("fulfillmentText")
log.saveConversations(query_text, fulfillmentText, intent, db)
elif intent == "NonVeg":
fulfillmentText = result.get("fulfillmentText")
log.saveConversations(query_text, fulfillmentText, intent, db)
elif intent == "NonVeg":
fulfillmentText = result.get("fulfillmentText")
log.saveConversations(query_text, fulfillmentText, intent, db)
elif intent == "Toppings":
fulfillmentText = result.get("fulfillmentText")
log.saveConversations(query_text, fulfillmentText, intent, db)
elif intent == "Toppings2":
fulfillmentText = result.get("fulfillmentText")
log.saveConversations(query_text, fulfillmentText, intent, db)
elif intent == "Order":
fulfillmentText = result.get("fulfillmentText")
log.saveConversations(query_text, fulfillmentText, intent, db)
elif intent == "Quantity":
fulfillmentText = result.get("fulfillmentText")
log.saveConversations(query_text, fulfillmentText, intent, db)
elif intent == "Mobile_number":
fulfillmentText = result.get("fulfillmentText")
log.saveConversations(query_text, fulfillmentText, intent, db)
elif intent == "Size":
fulfillmentText = result.get("fulfillmentText")
log.saveConversations(query_text, fulfillmentText, intent, db)
elif intent == "Address":
fulfillmentText = result.get("fulfillmentText")
log.saveConversations(query_text, fulfillmentText, intent, db)
if __name__ == '__main__':
app.run(debug=True,port=3000)