<s> import re <EOL> import inspect <EOL> from flask import redirect <EOL> from werkzeug . routing import HTTPException , RoutingException <EOL> def slugify ( value ) : <EOL> """<STR_LIT>""" <EOL> if type ( value ) == unicode : <EOL> import unicodedata <EOL> value = unicodedata . normalize ( '<STR_LIT>' , value ) . encode ( '<STR_LIT:ascii>' , '<STR_LIT:ignore>' ) <EOL> value = unicode ( re . sub ( '<STR_LIT>' , '<STR_LIT>' , value ) . strip ( ) . lower ( ) ) <EOL> return re . sub ( '<STR_LIT>' , '<STR_LIT:->' , value ) <EOL> class Redirect303 ( HTTPException , RoutingException ) : <EOL> """<STR_LIT>""" <EOL> code = <NUM_LIT> <EOL> def __init__ ( self , new_url ) : <EOL> RoutingException . __init__ ( self , new_url ) <EOL> self . new_url = new_url <EOL> def get_response ( self , environ ) : <EOL> return redirect ( self . new_url , <NUM_LIT> ) <EOL> class PrefixedWSGI ( object ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , app ) : <EOL> self . app = app <EOL> self . wsgi_app = app . wsgi_app <EOL> def __call__ ( self , environ , start_response ) : <EOL> script_name = self . app . config [ '<STR_LIT>' ] <EOL> if script_name : <EOL> environ [ '<STR_LIT>' ] = script_name <EOL> path_info = environ [ '<STR_LIT>' ] <EOL> if path_info . startswith ( script_name ) : <EOL> environ [ '<STR_LIT>' ] = path_info [ len ( script_name ) : ] <EOL> scheme = environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if scheme : <EOL> environ [ '<STR_LIT>' ] = scheme <EOL> return self . wsgi_app ( environ , start_response ) </s>
