#NEWLINE# def _register_file_server( self , app ) : #NEWLINE# #INDENT# "\n        File server\n        Only local files can be served\n        It's recommended to serve static files through NGINX instead of Python\n        Use this for development only\n        :param app: Flask app instance\n\n        " #NEWLINE# if ( isinstance ( self . driver , local . LocalStorageDriver ) and self . config [ 'serve_files' ] ) : #NEWLINE# #INDENT# server_url = self . config [ 'serve_files_url' ] . strip ( '/' ) . strip ( ) #NEWLINE# if server_url : #NEWLINE# #INDENT# url = ( '/%s/<path:object_name>' % server_url ) #NEWLINE# @ app . route ( url , endpoint = SERVER_ENDPOINT ) #NEWLINE# def files_server( object_name ) : #NEWLINE# #INDENT# obj = self . get ( object_name ) #NEWLINE# if ( obj is not None ) : #NEWLINE# #INDENT# dl = request . args . get ( 'dl' ) #NEWLINE# name = request . args . get ( 'name' , obj . name ) #NEWLINE# if ( get_file_extension ( name ) != obj . extension ) : #NEWLINE# #INDENT# name += ( '.%s' % obj . extension ) #NEWLINE# #UNINDENT# _url = obj . get_cdn_url ( ) #NEWLINE# return send_file ( _url , as_attachment = ( True if dl else False ) , attachment_filename = name , conditional = True ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# abort ( 404 ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# warnings . warn ( "Flask-Cloudy can't serve files. 'STORAGE_SERVER_FILES_URL' is not set" )