diff --git a/README.md b/README.md index 6a523ecb7ae445f5b39dd4fc58ec8f93c702f171..67d7d63d05d0238a346f9eb5045521dc52079893 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ # PizzaPalace GCSE Computer Science Challenge -## Installation +## Running the Server ``` git clone https://github.com/TheJoeCoder/PizzaPalace cd PizzaPalace pip install -r requirements.txt -echo "SECRET_KEY = 'SOME_KEY'" > app/config.py -python -m flask --app=pizza run +cd server +cp config.py.example config.py +python app.py ``` \ No newline at end of file diff --git a/client/config.py.example b/client/config.py.example new file mode 100644 index 0000000000000000000000000000000000000000..fcc88b7ef9e47ce492903f4ea06b321eb43476b2 --- /dev/null +++ b/client/config.py.example @@ -0,0 +1 @@ +api_url="https://api.example.com/" \ No newline at end of file diff --git a/client/pizza_palace.py b/client/pizza_palace.py index 5da131cba17c9eaf49217570d13358619a994b36..c1f644c5231adbe83dc863ea7fc4915d8761a1ff 100644 --- a/client/pizza_palace.py +++ b/client/pizza_palace.py @@ -1 +1,43 @@ -import tkinter +import json +from tkinter import ttk, messagebox + +## Init +root = Tk() + +## Global Variables +name = StringVar() +age = StringVar() + +## Subroutines +def submit(*args): + messagebox.showinfo("Not implemented") + +## Main program code +root.title("Pizza Palace") + +mainframe = ttk.Frame(root, padding="3 3 12 12") +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)) + +for child in mainframe.winfo_children(): + child.grid_configure(padx=5, pady=5) + +name_entry.focus() +root.bind("<Return>", submit) + +root.mainloop() diff --git a/server/app.py b/server/app.py index e110e3018eb222d7e639a1f0451c2b5263feb464..12f6d04ff89008c9ae3fe0ac9ffb6feb7675615d 100644 --- a/server/app.py +++ b/server/app.py @@ -1,10 +1,26 @@ -from flask import Flask, render_template, url_for +import json +from flask import Flask, request, jsonify, Response app = Flask(__name__) +import config + +with open("pizza_types.json","r") as f: + pizza_types = json.loads(f.read()) + +open_carts = {} + @app.route("/") def hello_world(): - return render_template("index.html") + return "{\"status\":200, \"message\": \"ok\"}", 200 + +@app.route("/pizzas", methods=["GET"]) +def get_pizzas(): + return jsonify(pizza_types), 200 + +@app.route("/cart/open", methods=["POST"]) +def open_cart(): + return "{\"status\":404, \"message\": \"not implemented\"}", 404 if __name__ == "__main__": app.run() \ No newline at end of file diff --git a/server/config.py.example b/server/config.py.example new file mode 100644 index 0000000000000000000000000000000000000000..1fed35b7f70763abb873a5ee08c116752f1edb81 --- /dev/null +++ b/server/config.py.example @@ -0,0 +1 @@ +webhook = "https://example.com/webhook" \ No newline at end of file diff --git a/server/pizza_types.json b/server/pizza_types.json new file mode 100644 index 0000000000000000000000000000000000000000..866ed59446a48c142820c60ad726eada9df2ca07 --- /dev/null +++ b/server/pizza_types.json @@ -0,0 +1,32 @@ +[ + { + "id": "margherita", + "name": "Margherita", + "cost_pp": 3, + "stuffed_pp": 1 + }, + { + "id": "pepperoni", + "name": "Pepperoni", + "cost_pp": 3, + "stuffed_pp": 1 + }, + { + "id": "hawaiian", + "name": "Hawaiian", + "cost_pp": 4, + "stuffed_pp": 1 + }, + { + "id": "buffalo_chicken", + "name": "Buffalo Chicken", + "cost_pp": 5, + "stuffed_pp": 1 + }, + { + "id": "veg_feast", + "name": "Vegetable Feast", + "cost_pp": 4, + "stuffed_pp": 1 + } +] \ No newline at end of file