30 lines
815 B
Python
30 lines
815 B
Python
import json
|
|
from flask import Flask, render_template, request
|
|
|
|
app = Flask(__name__)
|
|
|
|
with open('steam.json') as file:
|
|
blob = json.load(file)
|
|
|
|
|
|
@app.route('/')
|
|
def root():
|
|
items = []
|
|
|
|
if request.args.get('sortby') == "name":
|
|
sortedblob = sorted(blob, key=lambda k: k['name'])
|
|
elif request.args.get('sortby') == "release_date":
|
|
sortedblob = sorted(blob, key=lambda k: k['release_date'])
|
|
elif request.args.get('sortby') == "price":
|
|
sortedblob = sorted(blob, key=lambda k: k['price'])
|
|
else:
|
|
sortedblob = blob # hoezo memory efficient werken?
|
|
|
|
for x in range(0,99):
|
|
items.append(sortedblob[x])
|
|
|
|
return render_template('poc.html', gfgn=blob[0], len=len(blob), items=items)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app.run('0.0.0.0', port=5001, debug=True) |