Esempio n. 1
0
def delete_file():
    error = False
    for filename in get_all_files():
        if not remove_file(filename):
            error = True
    if error:
        return 'some files were not deleted', 400
    else:
        return 'all files were deleted', 200
Esempio n. 2
0
def create_file():
    content = request.get_json(silent=True)
    filename = content['filename']
    content = content['content']
    if not filename or not content:
        return "empty filename or content", 400
    if filename in get_all_files():
        return "file already exist", 400
    if add_file(filename, content):
        return "CREATED", 201
    else:
        return "error while creating file", 400
Esempio n. 3
0
def read_file():
    list = {}
    list["files"] = get_all_files()
    return json.dumps(list), 200