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.
 
 
 
 

81 lines
2.1 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():
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()]
submit = request.args.get('submit', '').strip()
if submit:
if submit == 'add':
# if x not in xdex:
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)
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)
# @APP.route('/test', methods=['GET', 'POST'])
# def test():
# if request.args.get('submit', ''):
# form = request.args.get('submit', '').strip()
# text = request.args.get('text', '').strip()
# else:
# form = 'none'
# text = 'none'
# return flask.render_template('test.html', form=form, text=text)
if __name__ == '__main__':
APP.debug=True
APP.run(port=5009)