Beispiel #1
0
def create_folder():
    form = forms.NewFolderForm()
    if form.validate_on_submit():
        path = Path(form.parent_dir.data.strip("/")) / form.new_dir.data
        new_path = data.create_dir(str(path))
        flash("Folder successfully created.", "success")
        return redirect(f"/?path={new_path}")
    flash("Could not create folder.", "error")
    return redirect(request.referrer or "/")
Beispiel #2
0
def index():
    path = request.args.get("path", "")
    files = data.get_items(path=path)
    return render_template("home.html",
                           title="Home",
                           search_enabled=app.config["SEARCH_CONF"]["enabled"],
                           dir=files,
                           current_path=path,
                           new_folder_form=forms.NewFolderForm(),
                           delete_form=forms.DeleteFolderForm())
Beispiel #3
0
def index():
    path = request.args.get("path", "").lstrip("/")
    try:
        files = data.get_items(path=path)
    except FileNotFoundError:
        flash("Directory does not exist.", "error")
        return redirect("/")

    return render_template("home.html",
                           title=path or "root",
                           search_enabled=app.config["SEARCH_CONF"]["enabled"],
                           dir=files,
                           current_path=path,
                           new_folder_form=forms.NewFolderForm(),
                           delete_form=forms.DeleteFolderForm())