Skip to content
Snippets Groups Projects
Commit fd317caf authored by TheJoeCoder's avatar TheJoeCoder
Browse files

Make open cart function actually work in backend

parent 1b93af34
Branches
No related tags found
No related merge requests found
......@@ -20,17 +20,6 @@ mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
name_label = ttk.Label(mainframe, text="Pizza Type: ")
name_label.grid(column=1, row=1, sticky=(W, E))
name_entry = ttk.Entry(mainframe, width=10, textvariable=name)
name_entry.grid(column=2, row=1, sticky=(W, E))
age_label = ttk.Label(mainframe, text="Age: ")
age_label.grid(column=1, row=2, sticky=(W, E))
age_entry = ttk.Entry(mainframe, width=10, textvariable=age)
age_entry.grid(column=2, row=2, sticky=(W, E))
submit_button = ttk.Button(mainframe, text="Go!", command=submit)
submit_button.grid(column=2, row=3, sticky=(W, E))
......
import json
import json, uuid, logging
from flask import Flask, request, jsonify, Response
logger = logging.Logger(__name__)
app = Flask(__name__)
import config
......@@ -12,15 +14,25 @@ open_carts = {}
@app.route("/")
def hello_world():
# Return OK message
return "{\"status\":200, \"message\": \"ok\"}", 200
@app.route("/pizzas", methods=["GET"])
def get_pizzas():
# Return pizza types
return jsonify(pizza_types), 200
@app.route("/cart/open", methods=["POST"])
def open_cart():
return "{\"status\":404, \"message\": \"not implemented\"}", 404
# Generate cart id and ensure it is unique
foundunique = False
while not foundunique:
cart_id = str(uuid.uuid4())
if cart_id in open_carts:
logger.warn("Regenerating UUID for new cart - prev " + cart_id)
cart_key = str(uuid.uuid4())
# TODO append cart to list and send to user
return "{\"status\":200, \"id\": \"not implemented\", \"key\": \"not implemented\"}", 200
if __name__ == "__main__":
app.run()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment