#NEWLINE# def create_app( config , debug = False , testing = False , config_overrides = None ) : #NEWLINE# #INDENT# app = Flask ( __name__ ) #NEWLINE# app . config . from_object ( config ) #NEWLINE# app . debug = debug #NEWLINE# app . testing = testing #NEWLINE# if config_overrides : #NEWLINE# #INDENT# app . config . update ( config_overrides ) #NEWLINE# #UNINDENT# if ( not app . testing ) : #NEWLINE# #INDENT# logging . basicConfig ( level = logging . INFO ) #NEWLINE# #UNINDENT# with app . app_context ( ) : #NEWLINE# #INDENT# model = get_model ( ) #NEWLINE# model . init_app ( app ) #NEWLINE# #UNINDENT# oauth2 . init_app ( index , scopes = [ 'email' , 'profile' ] , authorize_callback = _request_user_info ) #NEWLINE# @ app . route ( '/logout' ) #NEWLINE# def logout( ) : #NEWLINE# #INDENT# del session [ 'profile' ] #NEWLINE# session . modified = True #NEWLINE# oauth2 . storage . delete ( ) #NEWLINE# return redirect ( ( request . referrer or '/' ) ) #NEWLINE# #UNINDENT# from . crud import crud #NEWLINE# app . register_blueprint ( crud , url_prefix = '/books' ) #NEWLINE# @ app . route ( '/' ) #NEWLINE# def index( ) : #NEWLINE# #INDENT# return redirect ( url_for ( 'crud.list' ) ) #NEWLINE# #UNINDENT# @ app . errorhandler ( 500 ) #NEWLINE# def server_error( e ) : #NEWLINE# #INDENT# return ( '\n        An internal error occurred: <pre>{}</pre>\n        See logs for full stacktrace.\n        ' . format ( e ) , 500 ) #NEWLINE# #UNINDENT# return app