<s> from collections import OrderedDict <EOL> from flask import Blueprint , current_app as app , redirect <EOL> from . . domain import Text <EOL> from . _common import route <EOL> blueprint = Blueprint ( '<STR_LIT>' , __name__ , url_prefix = "<STR_LIT:/>" ) <EOL> @ blueprint . route ( "<STR_LIT>" ) <EOL> def get_without_text ( key ) : <EOL> template = app . template_service . find ( key ) <EOL> return redirect ( route ( '<STR_LIT>' , key = template . key ) ) <EOL> @ blueprint . route ( "<STR_LIT>" , endpoint = '<STR_LIT>' ) <EOL> def get_with_text ( key , path ) : <EOL> """<STR_LIT>""" <EOL> template = app . template_service . find ( key ) <EOL> if template . key != key : <EOL> return redirect ( route ( '<STR_LIT>' , key = template . key , path = path ) ) <EOL> text = Text ( path ) <EOL> if text . path != path : <EOL> return redirect ( route ( '<STR_LIT>' , key = key , path = text . path ) ) <EOL> data = OrderedDict ( ) <EOL> data [ '<STR_LIT>' ] = OrderedDict ( ) <EOL> visible_url = route ( '<STR_LIT>' , key = key , path = path , _external = True ) <EOL> data [ '<STR_LIT>' ] [ '<STR_LIT>' ] = visible_url <EOL> code = app . link_service . encode ( key , path ) <EOL> masked_url = route ( '<STR_LIT>' , code = code , _external = True ) <EOL> data [ '<STR_LIT>' ] [ '<STR_LIT>' ] = masked_url <EOL> data [ '<STR_LIT>' ] = OrderedDict ( ) <EOL> data [ '<STR_LIT>' ] [ '<STR_LIT>' ] = "<STR_LIT>" . format ( k = key , u = visible_url ) <EOL> data [ '<STR_LIT>' ] [ '<STR_LIT>' ] = "<STR_LIT>" . format ( k = key , u = masked_url ) <EOL> return data <EOL> @ blueprint . route ( "<STR_LIT>" ) <EOL> def get_encoded ( code ) : <EOL> key , path = app . link_service . decode ( code ) <EOL> return redirect ( route ( '<STR_LIT>' , key = key , path = path ) ) </s>
