make creation of folder and files

This commit is contained in:
Wolfang Torres
2026-06-20 15:06:14 +08:00
parent fe54900bdf
commit ec08cc0624
2 changed files with 22 additions and 8 deletions

View File

@@ -59,11 +59,18 @@ def file_list(listing_path=""):
if request.method == "POST": if request.method == "POST":
form = request.form.to_dict() form = request.form.to_dict()
listing_path = Path(listing_path) listing_path = Path(listing_path)
path = listing_path / form['name']
if form['type'] == "folder":
api.create_folder(path)
return redirect(
(url_for("mainapp.file_list", listing_path=path))
)
elif form['type'] == "file":
process_file = ProcessFile(listing_path) process_file = ProcessFile(listing_path)
if process_file.absolute_input_file.is_file(): if process_file.absolute_input_file.is_file():
listing_path = listing_path.parent listing_path = listing_path.parent
return redirect( return redirect(
(url_for("mainapp.create", listing_path=listing_path / form["name"])) (url_for("mainapp.create", listing_path=path))
) )

View File

@@ -112,12 +112,19 @@
<li> <li>
<form id="text_form" method="POST"> <form id="text_form" method="POST">
<div class="fields"> <div class="fields">
<div>
<input type="radio" id="type1" name="type" value="file" />
<label for="type1">Create File</label>
<input type="radio" id="type2" name="type" value="folder" />
<label for="type2">Create Folder</label>
</div>
<br />
<label for="name">File Name:</label> <label for="name">File Name:</label>
<input type="text" id="name" name="name" required size="10" /> <input type="text" id="name" name="name" required size="10" />
<input <input
id="process_button" id="create_file_button"
type="submit" type="submit"
value="Create File" value="Create"
class="button primary" class="button primary"
/> />
</div> </div>