#NEWLINE# def create_app( config_module = None ) : #NEWLINE# #INDENT# app = Flask ( __name__ ) #NEWLINE# app . config . from_object ( ( config_module or os . environ . get ( 'FLASK_CONFIG' ) or 'config' ) ) #NEWLINE# db . init_app ( app ) #NEWLINE# from api.v1 import api as api_blueprint #NEWLINE# app . register_blueprint ( api_blueprint , url_prefix = '/v1' ) #NEWLINE# if app . config [ 'USE_TOKEN_AUTH' ] : #NEWLINE# #INDENT# from api.token import token as token_blueprint #NEWLINE# app . register_blueprint ( token_blueprint , url_prefix = '/auth' ) #NEWLINE# #UNINDENT# @ app . route ( '/' ) #NEWLINE# @ auth . login_required #NEWLINE# @ etag #NEWLINE# @ json #NEWLINE# def index( ) : #NEWLINE# #INDENT# from api.v1 import get_catalog as v1_catalog #NEWLINE# return { #NEWLINE# #INDENT# 'versions' : { #NEWLINE# #INDENT# 'v1' : v1_catalog ( ) , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# @ app . errorhandler ( 404 ) #NEWLINE# @ auth . login_required #NEWLINE# def not_found_error( e ) : #NEWLINE# #INDENT# return not_found ( 'item not found' ) #NEWLINE# #UNINDENT# @ app . errorhandler ( 405 ) #NEWLINE# def method_not_allowed_error( e ) : #NEWLINE# #INDENT# return not_allowed ( ) #NEWLINE# #UNINDENT# return app