<s> import os <EOL> import os . path <EOL> import cgi <EOL> import cgitb <EOL> cgitb . enable ( ) <EOL> import urllib <EOL> prefix = os . environ [ '<STR_LIT>' ] [ : os . environ [ '<STR_LIT>' ] . find ( <EOL> '<STR_LIT>' ) ] <EOL> https_on = os . environ . has_key ( '<STR_LIT>' ) and os . environ [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> if https_on : <EOL> protocol = '<STR_LIT>' <EOL> else : <EOL> protocol = '<STR_LIT:http>' <EOL> url = protocol + '<STR_LIT>' + os . environ [ '<STR_LIT>' ] + prefix <EOL> htaccess_initial_path = os . path . normpath ( os . path . realpath ( __file__ ) + <EOL> '<STR_LIT>' ) <EOL> htaccess_path = os . path . normpath ( os . path . realpath ( __file__ ) + <EOL> '<STR_LIT>' ) <EOL> if not os . path . exists ( htaccess_path ) : <EOL> htaccess_initial_file = open ( htaccess_initial_path ) <EOL> htaccess_initial = htaccess_initial_file . read ( ) <EOL> htaccess_initial_file . close ( ) <EOL> htaccess = htaccess_initial . replace ( '<STR_LIT:$>' + protocol . upper ( ) + <EOL> '<STR_LIT>' , prefix ) <EOL> htaccess = htaccess . replace ( '<STR_LIT>' , <EOL> os . path . normpath ( os . path . realpath ( __file__ ) + '<STR_LIT>' ) ) <EOL> htaccess_file = open ( htaccess_path , '<STR_LIT:w>' ) <EOL> htaccess_file . write ( htaccess ) <EOL> htaccess_file . close ( ) <EOL> url = url + '<STR_LIT>' + urllib . quote_plus ( prefix ) <EOL> print """<STR_LIT>""" % ( url ) </s>
