#NEWLINE# @ csrf_exempt #NEWLINE# def serve( request , tail , server ) : #NEWLINE# #INDENT# "\n    Django adapter. It has three arguments:\n\n    #. ``request`` is a Django request object,\n    #. ``tail`` is everything that's left from an URL, which adapter is\n       attached to,\n    #. ``server`` is a pyws server object.\n\n    First two are the context of an application, function ``serve`` transforms\n    them into a pyws request object. Then it feeds the request to the server,\n    gets the response and transforms it into a Django response object.\n    " #NEWLINE# if request . GET : #NEWLINE# #INDENT# body = '' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# body = request . body #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# body = request . raw_post_data #NEWLINE# #UNINDENT# #UNINDENT# request = Request ( tail , body , parse_qs ( request . META [ 'QUERY_STRING' ] ) , parse_qs ( body ) , request . COOKIES ) #NEWLINE# response = server . process_request ( request ) #NEWLINE# return HttpResponse ( response . text , content_type = response . content_type , status = get_http_response_code_num ( response ) )