Beispiel #1
0
def api_tasks(task_id):
    """ Get task by id
    """
    # try to get task with completions first
    task_data = db.get_completion(task_id)
    task_data = db.get_task(task_id) if task_data is None else task_data
    return make_response(jsonify(task_data), 200)
Beispiel #2
0
def index():
    """ Main page: index.html
    """
    global c

    # load config at each page reload (for fast changing of config/input_path/output_path)
    c = load_config()

    # find editor files to include in html
    editor_dir = c['editor']['build_path']
    editor_js_dir = os.path.join(editor_dir, 'js')
    editor_js = ['/static/editor/js/' + f for f in os.listdir(editor_js_dir) if f.endswith('.js')]
    editor_css_dir = os.path.join(editor_dir, 'css')
    editor_css = ['/static/editor/css/' + f for f in os.listdir(editor_css_dir) if f.endswith('.css')]

    # load editor config from XML
    label_config_line = config_line_stripped(open(c['label_config']).read())

    # task data: load task or task with completions if it exists
    task_data = None
    task_id = request.args.get('task_id', None)

    if task_id is not None:
        task_data = db.get_completion(task_id)
        if task_data is None:
            task_data = db.get_task(task_id)

    return flask.render_template('index.html', config=c, label_config_line=label_config_line,
                                 editor_css=editor_css, editor_js=editor_js,
                                 task_id=task_id, task_data=task_data)