def api_render_label_studio(): """ Label studio frontend rendering for iframe """ # get args project = project_get_or_create() config = request.args.get('config', request.form.get('config', '')) config = unquote(config) if not config: return make_response('No config in POST', status.HTTP_417_EXPECTATION_FAILED) # prepare example examples = data_examples(mode='editor_preview') task_data = { data_key: examples.get(data_type, '') for data_key, data_type in project.extract_data_types(config).items() } example_task_data = { 'id': 1764, 'data': task_data, 'project': project.id, 'created_at': '2019-02-06T14:06:42.000420Z', 'updated_at': '2019-02-06T14:06:42.000420Z' } # prepare context for html config_line = config_line_stripped(config) response = { 'label_config_line': config_line, 'task_ser': example_task_data } response.update(find_editor_files()) project.analytics.send(getframeinfo(currentframe()).function) return flask.render_template('render_ls.html', **response)
def api_render_label_studio(): """ Label studio frontend rendering for iframe """ global c global label_config_line # reload config at each page reload (for fast changing of config/input_path/output_path) reload_config() # get args full_editor = request.args.get('full_editor', False) config = request.args.get('config', request.form.get('config', '')) config = unquote(config) if not config: return make_response('No config in POST', status.HTTP_417_EXPECTATION_FAILED) # prepare example examples = data_examples(mode='editor_preview') task_data = { data_key: examples.get(data_type, '') for data_key, data_type in Project.extract_data_types(config).items() } example_task_data = { 'id': 1764, 'data': task_data, 'project': DEFAULT_PROJECT_ID, 'created_at': '2019-02-06T14:06:42.000420Z', 'updated_at': '2019-02-06T14:06:42.000420Z' } # prepare context for html config_line = config_line_stripped(config) response = { 'label_config_line': config_line, 'task_ser': example_task_data } response.update(find_editor_files()) analytics.send(getframeinfo(currentframe()).function) return flask.render_template('render_ls.html', **response)