Example #1
0
def elconnector(request):
    finder = connector({'URL':'/media/files/',
    'root':os.path.join(web_ui.settings.HWIOS_ROOT,'services','web_ui','media','files'),
    'tmbDir':'.tmb',
    'imgLib':'PIL'})

    if request.POST:
        if "cmd" in request.POST and request.POST["cmd"] == "upload":
            request.POST['upload[]'] = request.FILES.getlist('upload[]')

        finder.run(request.POST)
        return JSONResponse(finder.httpResponse)
    finder.run(request.GET)
    ret = HttpResponse(mimetype=finder.httpHeader["Content-type"])
    if finder.httpHeader["Content-type"] == "application/json":
        ret.content = HWIOS.tools.json_encode(finder.httpResponse)
    else:
        ret.content = finder.httpResponse
    for head in finder.httpHeader:
        if head != "Content-type":
            ret[head] =  finder.httpHeader[head]
    ret.status_code = finder.httpStatusCode
    return ret
Example #2
0
def elconnector(request):
    finder = connector({'URL':'/media/files/',
    'root':'/home/hwios/hwios/services/web_ui/media/files/',
    'tmbDir':'.tmb',
    'imgLib':'PIL'})

    if request.POST:
        if "cmd" in request.POST and request.POST["cmd"] == "upload":
            request.POST['upload[]'] = request.FILES.getlist('upload[]')

        finder.run(request.POST)
        return HttpResponse(json.dumps(finder.httpResponse))
    finder.run(request.GET)
    ret = HttpResponse(mimetype=finder.httpHeader["Content-type"])
    if finder.httpHeader["Content-type"] == "application/json":
        ret.content = json.dumps(finder.httpResponse)
    else:
        ret.content = finder.httpResponse
    for head in finder.httpHeader:
        if head != "Content-type":
            ret[head] =  finder.httpHeader[head]
    ret.status_code = finder.httpStatusCode
    return ret