From 6087c35ee68dbaa4aa8a3a3919833f88f4266f3f Mon Sep 17 00:00:00 2001 From: Marek Baczynski Date: Wed, 28 Nov 2018 21:07:50 +0100 Subject: [PATCH] Made kuk app great again --- admin.json | 1 + kukv1.py | 42 ++++++++++++++++++++++++++++++ templates/index-new.html | 55 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 admin.json create mode 100644 kukv1.py create mode 100644 templates/index-new.html diff --git a/admin.json b/admin.json new file mode 100644 index 0000000..f0df8aa --- /dev/null +++ b/admin.json @@ -0,0 +1 @@ +{"username":"davide","password":"AssarIsTheNewGoogle17"} \ No newline at end of file diff --git a/kukv1.py b/kukv1.py new file mode 100644 index 0000000..d4ac9e8 --- /dev/null +++ b/kukv1.py @@ -0,0 +1,42 @@ +import random +import operator +import json +from flask import Flask, Response, redirect, url_for, request, session, abort, render_template +from flask_login import LoginManager, UserMixin, login_required, login_user, logout_user, current_user +from sqlalchemy.sql import select, text +import datetime +app = Flask(__name__) + +#config +app.config.update( + DEBUG = True, + SECRET_KEY = 'secret_xxx', + SESSION_TYPE = 'memcached' +) + +db_engine = {} +db_metadata = {} +meals = {} + +def getLeaderboard(): + leaders = [] + leaders.append({'name':'marek', 'score':'34'}) + leaders.append({'name':'sven', 'score':'16'}) + return {} + +def getUpcomingMeals(): + meals = [] + meals.append({'id':1, 'kuk':'davide', 'eaters':['marek','sven','wille'], 'flavor_text':'Pizza', 'date':'Tuesday 21st of November', 'selection_deadline':'23 hours 14 minutes', 'status':0}) + meals.append({'id':2, 'kuk':'marek', 'eaters':['davide','sven','david', 'wille'], 'flavor_text':'Grzybowa', 'date':'Friday 23rd of November', 'selection_deadline':'3 Days 23 hours', 'status':0}) + return {} + +@app.route('/') +def index(): + return render_template('index-new.html', leaderboard=getLeaderboard(), upcomingMeals=getUpcomingMeals(), current_user_name='Wille') + +if __name__ == '__main__': + with open('admin.json') as f: + postgres_credentials = json.load(f) + db_engine, db_metadata = connect(postgres_credentials['username'], postgres_credentials['password'], 'kuk_app') + meals = sqlalchemy.Table('meals', db_metadata) + app.run('0.0.0.0') \ No newline at end of file diff --git a/templates/index-new.html b/templates/index-new.html new file mode 100644 index 0000000..4ff57ba --- /dev/null +++ b/templates/index-new.html @@ -0,0 +1,55 @@ + + + + KUKapp + + + + + + + +
+

Leaderboard

+
+ {% for person in leaderboard %} +
+ + {{ person['name'] }} + {{ person['score'] }} +
+ {% endfor %} +
+
+
+

Next Meal

+

Cook

+
+ Davide +
+

Eaters

+
+ Marek +
+
+ Sven +
+ +
+
+
+ + {{current_user_name}} +
LOGOUT
+
+
+ + \ No newline at end of file