forked from shakibyzn/3-tier-store-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
36 lines (26 loc) · 915 Bytes
/
app.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
from flask import Flask, render_template, request, jsonify
from businesslogic import ProductLogic
app = Flask(__name__)
product_logic = ProductLogic()
@app.route('/buy', methods=['POST'])
def buy():
data = request.get_json()
first_name = data['firstName']
last_name = data['lastName']
product_name = data['productName']
product_logic.insert_product(first_name, last_name, product_name)
return jsonify({'message': 'Purchase successful'})
@app.route('/show', methods=['GET'])
def show():
purchases = product_logic.get_purchases()
return jsonify(purchases)
@app.route('/purchaseHistory', methods=['POST'])
def purchase_history():
data = request.get_json()
full_name = data['fullName']
history = product_logic.get_purchase_history(full_name)
return jsonify(history)
if __name__ == '__main__':
app.run()
def index():
return render_template('index.html')