def config_from_file(): try: config_file = INPUT_ARGUMENTS_PATH.open(encoding='utf8') except OSError: raise LabelStudioError("Can't open input_args file: " + str(INPUT_ARGUMENTS_PATH) + ", " "use set_input_arguments_path() to setup it") with config_file: data = json.load(config_file) return LabelStudioConfig(input_args=SimpleNamespace(**data))
def create_app(label_studio_config=None): """ Create application factory, as explained here: http://flask.pocoo.org/docs/patterns/appfactories/. :param label_studio_config: LabelStudioConfig object to use with input_args params """ app = flask.Flask(__package__, static_url_path='') app.secret_key = 'A0Zrdqwf1AQWj12ajkhgFN]dddd/,?RfDWQQT' app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0 app.config['WTF_CSRF_ENABLED'] = False app.url_map.strict_slashes = False app.label_studio = label_studio_config or config_from_file() # check LabelStudioConfig correct loading if app.label_studio is None: raise LabelStudioError('LabelStudioConfig is not loaded correctly') app.register_blueprint(blueprint) return app