added public gallery
This commit is contained in:
parent
bd8e83426a
commit
2815e9e029
18
fileHost.py
18
fileHost.py
|
@ -323,6 +323,24 @@ def manage_uploads():
|
|||
return redirect(url_for("manage_uploads"))
|
||||
|
||||
|
||||
@app.route("/gallery/<path:username>", 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():
|
||||
"""
|
||||
|
|
22
templates/gallery.html
Normal file
22
templates/gallery.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{ user }}'s gallery</title>
|
||||
</head>
|
||||
<body>
|
||||
<pre>
|
||||
<table>
|
||||
<tr>
|
||||
<th>File</th>
|
||||
<th>Date Uploaded</th>
|
||||
</tr>
|
||||
{% for file, date in uploads %}
|
||||
<tr>
|
||||
<td><a href="{{ upload_url + file }}">{{ file }}</a></td>
|
||||
<td>{{ date }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -4,6 +4,7 @@
|
|||
<title>Manage your uploads</title>
|
||||
</head>
|
||||
<body>
|
||||
<pre>
|
||||
<form method="post" enctype="multipart/form-data" action="{{ url_for('manage_uploads') }}">
|
||||
<table>
|
||||
<tr>
|
||||
|
@ -21,5 +22,6 @@
|
|||
</table>
|
||||
<input type="submit" value="Delete this" name="submit"/>
|
||||
</form>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue
Block a user