#NEWLINE# @ app . route ( '/add' , methods = [ 'POST' ] ) #NEWLINE# def add( ) : #NEWLINE# #INDENT# storm_ = app . get_storm ( ) #NEWLINE# try : #NEWLINE# #INDENT# name = request . json [ 'name' ] #NEWLINE# connection_uri = request . json [ 'connection_uri' ] #NEWLINE# if ( 'id_file' in request . json ) : #NEWLINE# #INDENT# id_file = request . json [ 'id_file' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# id_file = '' #NEWLINE# #UNINDENT# if ( '@' in name ) : #NEWLINE# #INDENT# msg = 'invalid value: "@" cannot be used in name.' #NEWLINE# return ( jsonify ( message = msg ) , 400 ) #NEWLINE# #UNINDENT# ( user , host , port ) = parse ( connection_uri ) #NEWLINE# storm_ . add_entry ( name , host , user , port , id_file ) #NEWLINE# return response ( status = 201 ) #NEWLINE# #UNINDENT# except ValueError as exc : #NEWLINE# #INDENT# return jsonify ( message = exc . message ) #NEWLINE# #UNINDENT# except ( KeyError , TypeError ) : #NEWLINE# #INDENT# return response ( status = 400 )