#NEWLINE# @ v1 . route ( '/new' , methods = [ 'POST' , 'GET' ] ) #NEWLINE# @ post_only #NEWLINE# def new( ) : #NEWLINE# #INDENT# '\n    Endpoint for creating a new paste.\n    ' #NEWLINE# form = request . form #NEWLINE# text = form . get ( 'text' ) #NEWLINE# if ( text is None ) : #NEWLINE# #INDENT# return ( jsonify ( error = 'required value missing: text' ) , 400 ) #NEWLINE# #UNINDENT# unlisted = form . get ( 'unlisted' , 'f' ) #NEWLINE# if ( unlisted . lower ( ) in ( '1' , 'true' , 't' , 'y' ) ) : #NEWLINE# #INDENT# unlisted = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# unlisted = False #NEWLINE# #UNINDENT# paste = { #NEWLINE# #INDENT# 'text' : text , #NEWLINE# 'title' : form . get ( 'title' ) , #NEWLINE# 'language' : form . get ( 'lang' , 'text' ) , #NEWLINE# 'password' : form . get ( 'password' ) , #NEWLINE# 'unlisted' : unlisted , #NEWLINE# #UNINDENT# } #NEWLINE# p = Paste . new ( ** paste ) #NEWLINE# if ( not Paste ) : #NEWLINE# #INDENT# return internal_server_error ( ) #NEWLINE# #UNINDENT# response = { #NEWLINE# #INDENT# 'url' : create_paste_url ( p ) , #NEWLINE# 'shorturl' : p [ 'shortlink' ] , #NEWLINE# 'paste' : create_paste_dict ( p ) , #NEWLINE# 'password' : paste [ 'password' ] , #NEWLINE# #UNINDENT# } #NEWLINE# return jsonify ( response )