diff --git a/main.py b/main.py index a38b5ca..3c37849 100644 --- a/main.py +++ b/main.py @@ -38,6 +38,7 @@ def init_db(): id INTEGER PRIMARY KEY AUTOINCREMENT, filename TEXT NOT NULL, subscriber_name TEXT NOT NULL, + description TEXT, uploaded_at TIMESTAMP NOT NULL, posted BOOLEAN DEFAULT 0 ) @@ -68,6 +69,7 @@ def upload(): file = request.files["picture"] subscriber_name = request.form.get("subscriber_name") + description = request.form.get("description", "").strip() if file.filename == "": flash("No file selected") @@ -85,8 +87,8 @@ def upload(): with get_db() as db: db.execute( - "INSERT INTO pet_pictures (filename, subscriber_name, uploaded_at) VALUES (?, ?, ?)", - (filename, subscriber_name, datetime.now()), + "INSERT INTO pet_pictures (filename, subscriber_name, description, uploaded_at) VALUES (?, ?, ?, ?)", + (filename, subscriber_name, description, datetime.now()), ) db.commit() diff --git a/templates/index.html b/templates/index.html index e126d74..8846c31 100644 --- a/templates/index.html +++ b/templates/index.html @@ -31,6 +31,9 @@ endblock %} {% block content %}
{{ picture.description }}
+ {% endif %}Uploaded: {{ picture.uploaded_at }}
+