<s> import re <EOL> from django . conf import settings <EOL> from staticgenerator import StaticGenerator <EOL> class StaticGeneratorMiddleware ( object ) : <EOL> """<STR_LIT>""" <EOL> urls = tuple ( [ re . compile ( url ) for url in settings . STATIC_GENERATOR_URLS ] ) <EOL> gen = StaticGenerator ( ) <EOL> def process_response ( self , request , response ) : <EOL> if response . status_code == <NUM_LIT:200> : <EOL> for url in self . urls : <EOL> if url . match ( request . path_info ) : <EOL> self . gen . publish_from_path ( request . path_info , response . content ) <EOL> break <EOL> return response </s>
