|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import sys, os
|
|
|
|
import flask
|
|
|
|
from flask import request, redirect, url_for
|
|
|
|
|
|
|
|
from functions import *
|
|
|
|
|
|
|
|
# Create the application.
|
|
|
|
APP = flask.Flask(__name__)
|
|
|
|
|
|
|
|
@APP.route('/', methods=['GET', 'POST'])
|
|
|
|
def index():
|
|
|
|
code = request.args.get('code', '').strip()
|
|
|
|
fixed1 = request.args.get('fixed1', '').strip()
|
|
|
|
fixed2 = request.args.get('fixed2', '').strip()
|
|
|
|
loose = request.args.get('loose', '').strip()
|
|
|
|
score = request.args.get('score', '').strip()
|
|
|
|
comment = request.args.get('comment', '').strip()
|
|
|
|
status = request.args.get('status', '').strip()
|
|
|
|
x = request.args.get('x', '').strip()
|
|
|
|
xdex, lastx = load_db('xdex.json')
|
|
|
|
entries = [x for x in xdex.keys()]
|
|
|
|
xs = sorted(xdex, reverse=True)
|
|
|
|
|
|
|
|
submit = request.args.get('submit', '').strip()
|
|
|
|
|
|
|
|
if submit:
|
|
|
|
if submit == 'add':
|
|
|
|
if x:
|
|
|
|
# new entry
|
|
|
|
xdex[x] = {}
|
|
|
|
xdex[x]['code'] = code
|
|
|
|
xdex[x]['fixed1'] = fixed1
|
|
|
|
xdex[x]['fixed2'] = fixed2
|
|
|
|
xdex[x]['loose'] = loose
|
|
|
|
xdex[x]['score'] = score
|
|
|
|
xdex[x]['comment'] = comment
|
|
|
|
xdex[x]['status'] = '-'
|
|
|
|
write_db('xdex.json', xdex)
|
|
|
|
xs.insert(0, x)
|
|
|
|
else:
|
|
|
|
# editing entry
|
|
|
|
x = submit
|
|
|
|
xdex[x]['code'] = code
|
|
|
|
xdex[x]['score'] = score
|
|
|
|
xdex[x]['comment'] = comment
|
|
|
|
xdex[x]['status'] = status
|
|
|
|
if status == 'delete':
|
|
|
|
del xdex[x]
|
|
|
|
write_db('xdex.json', xdex)
|
|
|
|
return redirect(url_for('index'))
|
|
|
|
|
|
|
|
return flask.render_template('x-dex.html', xdex=xdex, xs=xs)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
APP.debug=True
|
|
|
|
APP.run(port=5009)
|