From 2815e9e02965a841b363d123ff0c41a13b8c2b8e Mon Sep 17 00:00:00 2001 From: iou1name Date: Tue, 22 May 2018 09:42:02 -0400 Subject: [PATCH] added public gallery --- fileHost.py | 18 ++++++++++++++++++ templates/gallery.html | 22 ++++++++++++++++++++++ templates/manage_uploads.html | 2 ++ 3 files changed, 42 insertions(+) create mode 100644 templates/gallery.html diff --git a/fileHost.py b/fileHost.py index b08413b..d0d5ae9 100755 --- a/fileHost.py +++ b/fileHost.py @@ -323,6 +323,24 @@ def manage_uploads(): return redirect(url_for("manage_uploads")) +@app.route("/gallery/", methods=["GET"]) +def gallery(username): + """ + Displays a publicly accessable gallery of files the user has uploaded. + """ + if not verify_username(username): + return "User not found, or user has gallery disabled." + uploads = db_execute( + "SELECT filename, uploaded_date FROM uploads WHERE uploaded_by = ?", + (username,)).fetchall() + new_uploads = [] + for file, date in uploads: + date = datetime.fromtimestamp(date).strftime("%Y-%m-%d %H:%M") + new_uploads.append((file, date)) + return render_template("gallery.html", uploads=new_uploads, user=username, + upload_url=app.config.get("UPLOAD_URL")) + + @app.route("/", methods=["POST", "GET"]) def index(): """ diff --git a/templates/gallery.html b/templates/gallery.html new file mode 100644 index 0000000..a7ee110 --- /dev/null +++ b/templates/gallery.html @@ -0,0 +1,22 @@ + + + + {{ user }}'s gallery + + +
+
+	
+		
+		
+	
+	{% for file, date in uploads %}
+	
+		
+		
+	
+	{% endfor %}
+
FileDate Uploaded
{{ file }}{{ date }}
+
+ + diff --git a/templates/manage_uploads.html b/templates/manage_uploads.html index a38da1b..9748640 100644 --- a/templates/manage_uploads.html +++ b/templates/manage_uploads.html @@ -4,6 +4,7 @@ Manage your uploads +
 
@@ -21,5 +22,6 @@
+