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.
 
 
 
 

67 lines
1.8 KiB

#!/usr/bin/env python3
import sys, os
import flask
from flask import request, redirect, url_for
from werkzeug.utils import secure_filename
from functions import *
from flaskext.markdown import Markdown
# Upload settings
UPLOAD_FOLDER_TRACES = 'static/traces/'
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
# Create the application.
APP = flask.Flask(__name__)
APP.config['UPLOAD_FOLDER_TRACES'] = UPLOAD_FOLDER_TRACES
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
@APP.route('/', methods=['GET', 'POST'])
def index():
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()
x = request.args.get('x', '').strip()
xdex, lastx = load_db('xdex.json')
entries = [x for x in xdex.keys()]
update = request.args.get('update', '').strip()
if update:
# editing entry
x = update
score = request.args.get('score-{}'.format(x), '').strip()
comment = request.args.get('comment-{}'.format(x), '').strip()
status = request.args.get('status-{}'.format(x), '').strip()
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'))
elif x:
if x not in xdex:
# new entry
xdex[x] = {}
xdex[x]['fixed1'] = fixed1
xdex[x]['fixed2'] = fixed2
xdex[x]['loose'] = loose
xdex[x]['score'] = score
xdex[x]['comment'] = comment
xdex[x]['trace'] = ''
xdex[x]['status'] = '-'
write_db('xdex.json', xdex)
return flask.render_template('x-dex.html', xdex=xdex)
if __name__ == '__main__':
APP.debug=True
APP.run(port=5009)