You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
2.2 KiB
46 lines
2.2 KiB
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 leaders
|
|
|
|
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})
|
|
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})
|
|
meals.append({'id':2, 'kuk':'marek', 'eaters':['davide','sven','david', 'wille'], 'flavor_text':'Grzybowa', 'date':'Sunday 25rd of November', 'selection_deadline':'3 Days 23 hours', 'status':0})
|
|
meals.append({'id':2, 'kuk':'marek', 'eaters':['davide','sven','david', 'wille'], 'flavor_text':'Grzybowa', 'date':'Sunday 25rd of November', 'selection_deadline':'3 Days 23 hours', 'status':0})
|
|
meals.append({'id':2, 'kuk':'marek', 'eaters':['davide','sven','david', 'wille'], 'flavor_text':'Grzybowa', 'date':'Monday 26rd of November', 'selection_deadline':'3 Days 23 hours', 'status':0})
|
|
return meals
|
|
|
|
@app.route('/')
|
|
def index():
|
|
return render_template('meal_list.html', leaderboard=getLeaderboard(), meals=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') |