forked from bweber1205/orderExample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
46 lines (38 loc) · 1.41 KB
/
app.py
File metadata and controls
46 lines (38 loc) · 1.41 KB
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
import requests
from flask import Flask, render_template, request
from Product import Store
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def order():
productList = Store()
if request.method == 'POST':
item = request.form['pizza_name']
quantity = int(request.form['quantity'])
price = productList.getPrize(item)
amount = price * quantity
print(amount)
# Create a new resource
response = requests.post(
'https://intense-dusk-05888.herokuapp.com/engine-rest/process-definition/key/payment-retrieval/start',
json={
"variables": {
"amount": {
"value": amount,
"type": "long"
},
"item": {
"value": item,
"type": "string"
}
}
})
print(response.content)
if response.status_code == 200:
jsonResponse = response.json()
instanceID = jsonResponse.get("id")
else:
instanceID = "null"
return render_template('response.html', item=item, amount=amount, quantity=quantity,code=response.status_code, instanceID=instanceID,message=response.content)
return render_template('order.html')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5002)