#NEWLINE# @ v1 . route ( '/get' ) #NEWLINE# def get( ) : #NEWLINE# #INDENT# p_id = request . args . get ( 'id' , None , type = int ) #NEWLINE# p_hash = request . args . get ( 'hash' , None ) #NEWLINE# password = request . args . get ( 'password' ) #NEWLINE# if p_hash : #NEWLINE# #INDENT# paste = Paste . by_hash ( p_hash ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if p_id : #NEWLINE# #INDENT# paste = Paste . by_id ( p_id ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( jsonify ( error = 'no id or hash supplied' ) , 400 ) #NEWLINE# #UNINDENT# #UNINDENT# if ( password is None ) : #NEWLINE# #INDENT# return ( jsonify ( error = 'paste not found' ) , 404 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( not p_hash ) and paste [ 'unlisted' ] ) : #NEWLINE# #INDENT# return ( jsonify ( error = 'paste is unlisted' ) , 400 ) #NEWLINE# #UNINDENT# #UNINDENT# if paste [ 'password' ] : #NEWLINE# #INDENT# if ( not password ) : #NEWLINE# #INDENT# return ( jsonify ( error = 'paste is password protected' ) , 401 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not Paste . password_match ( paste [ 'hash' ] , password ) ) : #NEWLINE# #INDENT# return ( jsonify ( error = 'incorrect password' ) , 401 ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return jsonify ( create_paste_dict ( paste ) , shorturl = paste [ 'shortlink' ] , url = create_paste_url ( paste ) )