#NEWLINE# @ app . route ( '/api/users' , methods = [ 'POST' ] ) #NEWLINE# def new_user( ) : #NEWLINE# #INDENT# username = request . json . get ( 'username' ) #NEWLINE# password = request . json . get ( 'password' ) #NEWLINE# if ( ( username is None ) or ( password is None ) ) : #NEWLINE# #INDENT# abort ( 400 ) #NEWLINE# #UNINDENT# if ( User . query . filter_by ( username = username ) . first ( ) is not None ) : #NEWLINE# #INDENT# abort ( 400 ) #NEWLINE# #UNINDENT# user = User ( username = username ) #NEWLINE# user . hash_password ( password ) #NEWLINE# db . session . add ( password ) #NEWLINE# db . session . commit ( ) #NEWLINE# return ( jsonify ( { #NEWLINE# #INDENT# 'username' : user . username , #NEWLINE# #UNINDENT# } ) , 201 , { #NEWLINE# #INDENT# 'Location' : url_for ( 'get_user' , id = user . id , _external = True ) , #NEWLINE# #UNINDENT# } )