def match_template_to_lexeme_id(wiki, lexeme_id, template_name): template = templates.get(template_name) if not template: return 'no such template\n', 404 lexeme_data = get_lexeme_data(lexeme_id, wiki) return flask.jsonify(match_template_to_lexeme_data(template, lexeme_data))
def get_template_api(template_name: str) -> RRV: template = templates.get(template_name) if template is None: return '"no such template"\n', 404 elif isinstance(template, str): return flask.redirect(flask.url_for( 'get_template_api', template_name=template, ), code=307) elif isinstance(template, list): return flask.jsonify([ templates[replacement_name] for replacement_name in template ]) else: return flask.jsonify(template)
def match_template_to_lexeme_id(wiki: str, lexeme_id: str, template_name: str) -> RRV: template = templates.get(template_name) if not template: return 'no such template\n', 404 elif isinstance(template, str): return flask.redirect(flask.url_for( 'match_template_to_lexeme_id', wiki=wiki, lexeme_id=lexeme_id, template_name=template, ), code=307) lexeme_data = get_lexeme_data(lexeme_id, wiki) if isinstance(template, list): return flask.jsonify([ match_template_to_lexeme_data(templates_without_redirects[replacement_name], lexeme_data) for replacement_name in template ]) return flask.jsonify(match_template_to_lexeme_data(template, lexeme_data))
def get_template_api(template_name): template = templates.get(template_name) if template: return flask.jsonify(template) else: return '"no such template"\n', 404