From dc787e4d947b27a534a7fe17a8938d6c53a2a8e5 Mon Sep 17 00:00:00 2001 From: benjamyn Date: Wed, 22 Jan 2020 21:53:08 +1100 Subject: [PATCH] In sync with dev Added mobile view --- shop.py | 9 +++-- static/css/{index.css => main.css} | 0 templates/index.html | 2 +- templates/mobile.html | 57 ++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 3 deletions(-) rename static/css/{index.css => main.css} (100%) create mode 100644 templates/mobile.html diff --git a/shop.py b/shop.py index 6bed573..f41392d 100644 --- a/shop.py +++ b/shop.py @@ -4,6 +4,8 @@ import sqlite3 import os.path DBNAME = "list.db" +MOBILES = ["android", "iphone", "blackberry"] + def doesDBExist(DBNAME): try: @@ -61,7 +63,10 @@ app.config["DEBUG"] = True @app.route('/') def index(): query = readFromDB() - data = {"title":"Cart", "results":query} + data = {"title":"Shopping List", "results":query} + for device in MOBILES: + if device in request.user_agent.platform: + return render_template('mobile.html', data=data) return render_template('index.html', data=data) @app.route('/post', methods=['POST']) @@ -84,4 +89,4 @@ def handle_data(): if __name__ == '__main__': doesDBExist(DBNAME) - app.run(host="0.0.0.0") \ No newline at end of file + app.run() diff --git a/static/css/index.css b/static/css/main.css similarity index 100% rename from static/css/index.css rename to static/css/main.css diff --git a/templates/index.html b/templates/index.html index 23031da..2c3b0c9 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,7 +5,7 @@ - +

{{ data["title"] }}

diff --git a/templates/mobile.html b/templates/mobile.html new file mode 100644 index 0000000..8f51a67 --- /dev/null +++ b/templates/mobile.html @@ -0,0 +1,57 @@ + + + + Shopping List + + + + + + +

{{ data["title"] }}

+
+
+ Name:
+ Item:

+ +
+
+
+ + + + + + + + + {% for x in data["results"] %} + + + + + + + + {% endfor %} +
ItemRequesterGottem?Remove
{{x[1]}}{{x[4]}} {% if x[3] == 0 %} +
+ {% else %} + yes + {% endif %}
+ +
+
+ +
+ + + + + + + + + + +