From 712c84b3583dd7932a8a6d68599e116b312012c9 Mon Sep 17 00:00:00 2001 From: coolneng Date: Wed, 8 Jan 2020 05:51:10 +0100 Subject: [PATCH] Add Flask webapp draft --- .gitignore | 1 - code/.env | 1 + code/Pipfile | 1 + code/Pipfile.lock | 61 ++++++++++++++++++++++------------- code/app/__init__.py | 5 +++ code/app/routes.py | 13 ++++++++ code/app/templates/base.html | 14 ++++++++ code/app/templates/index.html | 8 +++++ code/igdb.py | 1 + 9 files changed, 81 insertions(+), 24 deletions(-) create mode 100644 code/.env create mode 100644 code/app/__init__.py create mode 100644 code/app/routes.py create mode 100644 code/app/templates/base.html create mode 100644 code/app/templates/index.html create mode 100644 code/igdb.py diff --git a/.gitignore b/.gitignore index 5c46053..430f598 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ Assets/__titlepage.filled.tex Design.org -Code/.env diff --git a/code/.env b/code/.env new file mode 100644 index 0000000..cf02bc8 --- /dev/null +++ b/code/.env @@ -0,0 +1 @@ +FLASK_APP=igdb.py diff --git a/code/Pipfile b/code/Pipfile index 84c6e8d..ad15fdd 100644 --- a/code/Pipfile +++ b/code/Pipfile @@ -11,6 +11,7 @@ pymysql = "*" flask-sqlalchemy = "*" pandas = "*" iso3166 = "*" +flask-wtf = "*" [requires] python_version = "3.8" diff --git a/code/Pipfile.lock b/code/Pipfile.lock index 24a058d..ea74bfb 100644 --- a/code/Pipfile.lock +++ b/code/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "180a68bb151e2c8ab26c87081302da4bd38107869f77507d721f7502631c4684" + "sha256": "f4ff138e539e1c5bcdc3a3f5046b1d5087a0f0315d1a18181fc2c6eeb1227671" }, "pipfile-spec": 6, "requires": { @@ -39,6 +39,14 @@ "index": "pypi", "version": "==2.4.1" }, + "flask-wtf": { + "hashes": [ + "sha256:5d14d55cfd35f613d99ee7cba0fc3fbbe63ba02f544d349158c14ca15561cc36", + "sha256:d9a9e366b32dcbb98ef17228e76be15702cd2600675668bca23f63a7947fd5ac" + ], + "index": "pypi", + "version": "==0.14.2" + }, "iso3166": { "hashes": [ "sha256:b07208703bd881a4f974e39fa013c4498dddd64913ada15f24be75d02ae68a44", @@ -96,29 +104,29 @@ }, "numpy": { "hashes": [ - "sha256:03bbde29ac8fba860bb2c53a1525b3604a9b60417855ac3119d89868ec6041c3", - "sha256:1baefd1fb4695e7f2e305467dbd876d765e6edd30c522894df76f8301efaee36", - "sha256:1c35fb1131362e6090d30286cfda52ddd42e69d3e2bf1fea190a0fad83ea3a18", - "sha256:3c68c827689ca0ca713dba598335073ce0966850ec0b30715527dce4ecd84055", - "sha256:443ab93fc35b31f01db8704681eb2fd82f3a1b2fa08eed2dd0e71f1f57423d4a", - "sha256:56710a756c5009af9f35b91a22790701420406d9ac24cf6b652b0e22cfbbb7ff", - "sha256:62506e9e4d2a39c87984f081a2651d4282a1d706b1a82fe9d50a559bb58e705a", - "sha256:6f8113c8dbfc192b58996ee77333696469ea121d1c44ea429d8fd266e4c6be51", - "sha256:712f0c32555132f4b641b918bdb1fd3c692909ae916a233ce7f50eac2de87e37", - "sha256:854f6ed4fa91fa6da5d764558804ba5b0f43a51e5fe9fc4fdc93270b052f188a", - "sha256:88c5ccbc4cadf39f32193a5ef22e3f84674418a9fd877c63322917ae8f295a56", - "sha256:905cd6fa6ac14654a6a32b21fad34670e97881d832e24a3ca32e19b455edb4a8", - "sha256:9d6de2ad782aae68f7ed0e0e616477fbf693d6d7cc5f0f1505833ff12f84a673", - "sha256:a30f5c3e1b1b5d16ec1f03f4df28e08b8a7529d8c920bbed657f4fde61f1fbcd", - "sha256:a9d72d9abaf65628f0f31bbb573b7d9304e43b1e6bbae43149c17737a42764c4", - "sha256:ac3cf835c334fcc6b74dc4e630f9b5ff7b4c43f7fb2a7813208d95d4e10b5623", - "sha256:b091e5d4cbbe79f0e8b6b6b522346e54a282eadb06e3fd761e9b6fafc2ca91ad", - "sha256:cc070fc43a494e42732d6ae2f6621db040611c1dde64762a40c8418023af56d7", - "sha256:e1080e37c090534adb2dd7ae1c59ee883e5d8c3e63d2a4d43c20ee348d0459c5", - "sha256:f084d513de729ff10cd72a1f80db468cff464fedb1ef2fea030221a0f62d7ff4", - "sha256:f6a7421da632fc01e8a3ecd19c3f7350258d82501a646747664bae9c6a87c731" + "sha256:1786a08236f2c92ae0e70423c45e1e62788ed33028f94ca99c4df03f5be6b3c6", + "sha256:17aa7a81fe7599a10f2b7d95856dc5cf84a4eefa45bc96123cbbc3ebc568994e", + "sha256:20b26aaa5b3da029942cdcce719b363dbe58696ad182aff0e5dcb1687ec946dc", + "sha256:2d75908ab3ced4223ccba595b48e538afa5ecc37405923d1fea6906d7c3a50bc", + "sha256:39d2c685af15d3ce682c99ce5925cc66efc824652e10990d2462dfe9b8918c6a", + "sha256:56bc8ded6fcd9adea90f65377438f9fea8c05fcf7c5ba766bef258d0da1554aa", + "sha256:590355aeade1a2eaba17617c19edccb7db8d78760175256e3cf94590a1a964f3", + "sha256:70a840a26f4e61defa7bdf811d7498a284ced303dfbc35acb7be12a39b2aa121", + "sha256:77c3bfe65d8560487052ad55c6998a04b654c2fbc36d546aef2b2e511e760971", + "sha256:9537eecf179f566fd1c160a2e912ca0b8e02d773af0a7a1120ad4f7507cd0d26", + "sha256:9acdf933c1fd263c513a2df3dceecea6f3ff4419d80bf238510976bf9bcb26cd", + "sha256:ae0975f42ab1f28364dcda3dde3cf6c1ddab3e1d4b2909da0cb0191fa9ca0480", + "sha256:b3af02ecc999c8003e538e60c89a2b37646b39b688d4e44d7373e11c2debabec", + "sha256:b6ff59cee96b454516e47e7721098e6ceebef435e3e21ac2d6c3b8b02628eb77", + "sha256:b765ed3930b92812aa698a455847141869ef755a87e099fddd4ccf9d81fffb57", + "sha256:c98c5ffd7d41611407a1103ae11c8b634ad6a43606eca3e2a5a269e5d6e8eb07", + "sha256:cf7eb6b1025d3e169989416b1adcd676624c2dbed9e3bcb7137f51bfc8cc2572", + "sha256:d92350c22b150c1cae7ebb0ee8b5670cc84848f6359cf6b5d8f86617098a9b73", + "sha256:e422c3152921cece8b6a2fb6b0b4d73b6579bd20ae075e7d15143e711f3ca2ca", + "sha256:e840f552a509e3380b0f0ec977e8124d0dc34dc0e68289ca28f4d7c1d0d79474", + "sha256:f3d0a94ad151870978fb93538e95411c83899c9dc63e6fb65542f769568ecfa5" ], - "version": "==1.18.0" + "version": "==1.18.1" }, "pandas": { "hashes": [ @@ -186,6 +194,13 @@ "sha256:e5f4a1f98b52b18a93da705a7458e55afb26f32bff83ff5d19189f92462d65c4" ], "version": "==0.16.0" + }, + "wtforms": { + "hashes": [ + "sha256:0cdbac3e7f6878086c334aa25dc5a33869a3954e9d1e015130d65a69309b3b61", + "sha256:e3ee092c827582c50877cdbd49e9ce6d2c5c1f6561f849b3b068c1b8029626f1" + ], + "version": "==2.2.1" } }, "develop": {} diff --git a/code/app/__init__.py b/code/app/__init__.py new file mode 100644 index 0000000..96c8ef5 --- /dev/null +++ b/code/app/__init__.py @@ -0,0 +1,5 @@ +from flask import Flask + +app = Flask(__name__) + +from app import routes diff --git a/code/app/routes.py b/code/app/routes.py new file mode 100644 index 0000000..772bbc8 --- /dev/null +++ b/code/app/routes.py @@ -0,0 +1,13 @@ +from app import app +from flask import render_template + + +@app.route("/") +@app.route("/index") +def index(): + user = {"username": "Bolaji"} + posts = [ + {"author": {"username": "Miloud"}, "body": "Beautiful day in Meknes!"}, + {"author": {"username": "Sebtaoui"}, "body": "The Farkouss movie was lit!"}, + ] + return render_template("index.html", title="Home", user=user, posts=posts) diff --git a/code/app/templates/base.html b/code/app/templates/base.html new file mode 100644 index 0000000..db4394d --- /dev/null +++ b/code/app/templates/base.html @@ -0,0 +1,14 @@ + + + {% if title %} + {{ title }} - IGDB + {% else %} + Welcome to IGDB + {% endif %} + + +
IGDB: Home
+
+ {% block content %}{% endblock %} + + diff --git a/code/app/templates/index.html b/code/app/templates/index.html new file mode 100644 index 0000000..b580e8c --- /dev/null +++ b/code/app/templates/index.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} + +{% block content %} +

Hi, {{ user.username }}!

+ {% for post in posts %} +

{{ post.author.username }} says: {{ post.body }}

+ {% endfor %} +{% endblock %} diff --git a/code/igdb.py b/code/igdb.py new file mode 100644 index 0000000..d099b92 --- /dev/null +++ b/code/igdb.py @@ -0,0 +1 @@ +from app import app