(request)
return HttpResponse(content=payload, content_type="text/plain")
GET request: Returns data
    PUT request: Updates file in data with given file.
GET request: Returns data
    PUT request: Updates file in data with given file.
GET request : Returns data PUT request : Updates file in data with given file .
def data_api(request):
    """
    GET request: Returns data
    PUT request: Updates file in data with given file.
    """

    uid = request.GET.get('uid', request.POST.get('uid'))
    data = Data.objects.filter(uid=uid).first()

    # Get the source that will replace target
    source = request.FILES.get("data", "")

    # Target first file in data directory.
    target = data.get_files()[0]

    if not target:
        msg = f"File does not exist."
        return HttpResponse(content=msg, content_type="text/plain")

    # Write source into target
    if request.method == "POST":
        # Validate source and target files before upload.
        valid, msg = auth.validate_file(source=source)
        if not valid:
            return HttpResponse(content=msg, content_type="text/plain")

        # Write source to target file.
        target = util.write_stream(stream=source, dest=target)

    # Return file contents in payload
    payload = open(target, 'r').read()

    return HttpResponse(content=payload, content_type="text/plain")
def data_api ( request ) : uid = request . GET . get ( 'uid' , request . POST . get ( 'uid' ) ) data = Data . objects . filter ( uid = uid ) . first ( ) # Get the source that will replace target source = request . FILES . get ( "data" , "" ) # Target first file in data directory. target = data . get_files ( ) [ 0 ] if not target : msg = f"File does not exist." return HttpResponse ( content = msg , content_type = "text/plain" ) # Write source into target if request . method == "POST" : # Validate source and target files before upload. valid , msg = auth . validate_file ( source = source ) if not valid : return HttpResponse ( content = msg , content_type = "text/plain" ) # Write source to target file. target = util . write_stream ( stream = source , dest = target ) # Return file contents in payload payload = open ( target , 'r' ) . read ( ) return HttpResponse ( content = payload , content_type = "text/plain" )