<s> """<STR_LIT>""" <EOL> from flask import Flask , render_template <EOL> from comport . settings import ProdConfig <EOL> from comport . assets import assets <EOL> from comport . extensions import ( <EOL> bcrypt , <EOL> cache , <EOL> db , <EOL> login_manager , <EOL> migrate , <EOL> debug_toolbar , <EOL> ) <EOL> from comport import ( public , user , admin , department , data , content , interest , template_globals ) <EOL> from flask_sslify import SSLify <EOL> import logging <EOL> import sys <EOL> import os <EOL> def create_app ( config_object = ProdConfig ) : <EOL> """<STR_LIT>""" <EOL> app = Flask ( __name__ ) <EOL> sslify = SSLify ( app ) <EOL> app . config . from_object ( config_object ) <EOL> register_extensions ( app ) <EOL> register_blueprints ( app ) <EOL> register_errorhandlers ( app ) <EOL> register_template_globals ( app ) <EOL> @ app . before_first_request <EOL> def before_first_request ( ) : <EOL> register_logging ( app ) <EOL> return app <EOL> def register_extensions ( app ) : <EOL> assets . init_app ( app ) <EOL> bcrypt . init_app ( app ) <EOL> cache . init_app ( app ) <EOL> db . init_app ( app ) <EOL> login_manager . init_app ( app ) <EOL> debug_toolbar . init_app ( app ) <EOL> migrate . init_app ( app , db ) <EOL> return None <EOL> def register_blueprints ( app ) : <EOL> app . register_blueprint ( public . views . blueprint ) <EOL> app . register_blueprint ( user . views . blueprint ) <EOL> app . register_blueprint ( admin . views . blueprint ) <EOL> app . register_blueprint ( department . views . blueprint ) <EOL> app . register_blueprint ( data . views . blueprint ) <EOL> app . register_blueprint ( content . views . blueprint ) <EOL> app . register_blueprint ( interest . views . blueprint ) <EOL> return None <EOL> def register_errorhandlers ( app ) : <EOL> def render_error ( error ) : <EOL> error_code = getattr ( error , '<STR_LIT:code>' , <NUM_LIT> ) <EOL> return render_template ( "<STR_LIT>" . format ( error_code ) ) , error_code <EOL> for errcode in [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] : <EOL> app . errorhandler ( errcode ) ( render_error ) <EOL> return None <EOL> def register_template_globals ( app ) : <EOL> app . jinja_env . globals . update ( markdown = template_globals . markdown ) <EOL> def register_logging ( app ) : <EOL> if '<STR_LIT>' in os . environ . get ( '<STR_LIT>' , [ ] ) : <EOL> print ( "<STR_LIT>" ) <EOL> app . logger . removeHandler ( app . logger . handlers [ <NUM_LIT:0> ] ) <EOL> app . logger . setLevel ( logging . DEBUG ) <EOL> stdout = logging . StreamHandler ( sys . stdout ) <EOL> stdout . setFormatter ( logging . Formatter ( <EOL> '''<STR_LIT>''' <EOL> ) ) <EOL> app . logger . addHandler ( stdout ) <EOL> else : <EOL> app . logger . setLevel ( logging . DEBUG ) <EOL> return None </s>
