def rest_user(filename):
            logging.info("Webservice user Receving....")
            users = nubexUser(logging, dbnubex)
            if filename == "register":
                username = request.form["username"]
                alias = request.form["alias"]
                password = request.form["password"]
                mail = request.form["mail"]
                response = users.register(username, alias, password, mail)
            elif filename == "login":
                username = request.form["username"]
                password = request.form["password"]
                response = users.login(username, password)
            elif filename == "delete":
                username = request.form["account"]
                account_name = request.form["account_name"]
                account_key = request.form["account_key"]
                account = users.get_account(account_name, account_key)
                isadmin = account.get("isadmin", "false")
                if account and isadmin == "true":
                    response = users.delete(username)
                else:
                    logging.critical("This account does not exists")
                    return '{ "success":"false", "msg":"Your account configuration seem to be incorrect" }'
            elif filename == "isadmin":
                account_name = request.form["account_name"]
                account_key = request.form["account_key"]
                account = users.get_account(account_name, account_key)
                isadmin = account.get("isadmin", "false")
                if account:
                    response = '{ "isadmin":"' + isadmin + '" }'
                else:
                    logging.critical("This account does not exists")
                    return '{ "success":"false", "msg":"Your account configuration seem to be incorrect" }'
            elif filename == "change_state":
                username = request.form["account"]
                state = request.form["state"]
                account_name = request.form["account_name"]
                account_key = request.form["account_key"]
                account = users.get_account(account_name, account_key)
                isadmin = account.get("isadmin", "false")
                if account and isadmin == "true":
                    response = users.change_state(username, state)
                else:
                    logging.critical("This account does not exists")
                    return '{ "success":"false", "msg":"Your account configuration seem to be incorrect" }'
            elif filename == "change_admin":
                username = request.form["account"]
                state = request.form["state"]
                account_name = request.form["account_name"]
                account_key = request.form["account_key"]
                account = users.get_account(account_name, account_key)
                isadmin = account.get("isadmin", "false")
                if account and isadmin == "true":
                    response = users.change_admin(username, state)
                else:
                    logging.critical("This account does not exists")
                    return '{ "success":"false", "msg":"Your account configuration seem to be incorrect" }'
            elif filename == "overall":
                account_name = request.form["account_name"]
                account_key = request.form["account_key"]
                account = users.get_account(account_name, account_key)
                if account:
                    files = nubexFile(logging, account_name)
                    sizetotalnum = int(account["size"])
                    if sizetotalnum == 0:
                        sizetotal = "Unlimited"
                    elif sizetotalnum < 1024:
                        sizetotal = str(sizetotalnum) + " KB"
                    elif sizetotalnum < 1024 * 1024:
                        sizetotal = str(sizetotalnum / 1024) + " MB"
                    else:
                        sizetotal = str(sizetotalnum / (1024 * 1024)) + " GB"

                    sizeusednum = files.file_accountsize()
                    if sizeusednum < 1024:
                        sizeused = str(sizeusednum) + " B"
                    elif sizeusednum < 1024 * 1024:
                        sizeused = str(sizeusednum / 1024) + " KB"
                    elif sizeusednum < 1024 * 1024 * 1024:
                        sizeused = str(sizeusednum / (1024 * 1024)) + " MB"
                    else:
                        sizeused = str(sizeusednum / (1024 * 1024 * 1024)) + " GB"

                    sizefreenum = (int(account["size"]) * 1024) - sizeusednum
                    if sizefreenum < 1024:
                        sizefree = str(sizefreenum) + " B"
                    elif sizefreenum < 1024 * 1024:
                        sizefree = str(sizefreenum / 1024) + " KB"
                    elif sizefreenum < 1024 * 1024 * 1024:
                        sizefree = str(sizefreenum / (1024 * 1024)) + " MB"
                    else:
                        sizefree = str(sizefreenum / (1024 * 1024 * 1024)) + " GB"

                    if sizetotalnum == 0:
                        sizepourcent = "75"
                    else:
                        sizepourcent = (100 * sizeusednum) / (sizetotalnum * 1024)

                    response = json.dumps(
                        {
                            "success": "true",
                            "username": account["username"],
                            "alias": account["alias"],
                            "mail": account["mail"],
                            "isadmin": account["isadmin"],
                            "accounttype": account["state"],
                            "sizetotal": sizetotal,
                            "sizeused": sizeused,
                            "sizefree": sizefree,
                            "sizepourcent": sizepourcent,
                        }
                    )
                else:
                    logging.critical("This account does not exists")
                    response = '{ "success":"false", "msg":"Your account configuration seem to be incorrect" }'
            elif filename == "list":
                account_name = request.form["account_name"]
                account_key = request.form["account_key"]
                account = users.get_account(account_name, account_key)
                isadmin = account.get("isadmin", "false")
                if account and isadmin == "true":
                    return users.get_list()
                else:
                    response = '{ "success":"false", "msg":"Restricted access to admin" }'

            return response
        def rest_file(filename):
            logging.info("Webservice file Receving....")
            users = nubexUser(logging, dbnubex)
            try:
                if request.method == "GET":
                    account_name = request.args["account_name"]
                    account_key = request.args["account_key"]
                else:
                    account_name = request.form["account_name"]
                    account_key = request.form["account_key"]
                account = users.isvalid(account_name, account_key)
            except:
                account = False

            if account:
                files = nubexFile(logging, account_name)
                if filename == "delete":
                    path = request.form["path"]
                    pathbase = request.form["pathbase"]
                    on_move = request.form["on_move"]
                    files.file_delete(path, pathbase, on_move)
                elif filename == "modify":
                    data = request.files["data"]
                    pathbase = request.form["pathbase"]
                    mimetype = request.form["mimetype"]
                    raw = ""
                    if data:
                        while True:
                            datachunk = data.read(1024)
                            if not datachunk:
                                break
                            raw = raw + datachunk

                    files.file_modify(data.filename, pathbase, raw, mimetype)
                elif filename == "move":
                    move_from = request.form["move_from"]
                    move_to = request.form["move_to"]
                    pathbase = request.form["pathbase"]
                    is_dir = request.form["is_dir"]
                    files.file_move(move_from, move_to, pathbase, is_dir)
                elif filename == "list":
                    try:
                        path = request.form["path"]
                    except:
                        path = ""
                    return files.file_list(path)
                elif filename == "get":
                    try:
                        path = request.args["path"]
                        fd = files.file_get(path)
                        (path_file, filename) = os.path.split(path)
                        response = make_response(fd.read(-1))
                        response.headers["Content-Type"] = fd.contentType
                        response.headers["Content-Disposition"] = "attachment; filename=" + filename
                        return response
                    except:
                        return '{ "success":"false", "msg":"Parameter problem" }'
                elif filename == "sync_get":
                    try:
                        path = request.form["path"]
                        timestamp = request.form["timestamp"]
                        fd = files.file_get(path, timestamp)
                        (path_file, filename) = os.path.split(path)
                        response = make_response(fd.read(-1))
                        response.headers["Content-Type"] = fd.contentType
                        response.headers["Content-Disposition"] = "attachment; filename=" + filename
                        return response
                    except:
                        return '{ "success":"false", "msg":"Parameter problem" }'
                else:
                    return '{ "success":"false", "msg":"This REST URL does not exists" }'
                return '{ "success":"true" }'
            else:
                logging.critical("This account does not exists")
                return '{ "success":"false", "msg":"Your account configuration seem to be incorrect" }'