#NEWLINE# @ app . after_request #NEWLINE# def after_request( response ) : #NEWLINE# #INDENT# response . headers . add ( 'Access-Control-Allow-Methods' , 'GET, POST' ) #NEWLINE# response . headers . add ( 'Access-Control-Allow-Credentials' , 'true' ) #NEWLINE# response . headers . add ( 'Access-Control-Allow-Headers' , 'Content-Type, *' ) #NEWLINE# response . headers . add ( 'Cache-Control' , 'no-cache' ) #NEWLINE# response . headers . add ( 'Cache-Control' , 'no-store' ) #NEWLINE# if api . auth . is_logged_in ( ) : #NEWLINE# #INDENT# if ( 'token' in session ) : #NEWLINE# #INDENT# response . set_cookie ( 'token' , session [ 'token' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# csrf_token = ( 'csrf_' + api . common . token ( ) ) #NEWLINE# session [ 'token' ] = csrf_token #NEWLINE# response . set_cookie ( 'token' , csrf_token ) #NEWLINE# #UNINDENT# #UNINDENT# return response