Add "Remove by" template

This commit is contained in:
TT-392 2024-11-27 23:55:50 +01:00 committed by Thijs Raymakers
parent 1746db8e37
commit 2e3d6bba32
No known key found for this signature in database
3 changed files with 20 additions and 2 deletions

19
app.py
View file

@ -3,7 +3,7 @@ from flask import Flask, render_template, request, redirect, url_for, session, s
from PIL import Image
from gen_image import gen_image
from config import *
from datetime import datetime
from datetime import *
from print import *
from process_image import *
from file_handler import *
@ -44,6 +44,19 @@ templates = {
"pos": 130
},
"cut": True
},
"Remove by": {
"text1": {
"string": "Remove by",
"size": 130,
"pos": 0
},
"text2": {
"string": "",
"size": 50,
"pos": 130
},
"cut": True
}
}
@ -140,9 +153,13 @@ def text_template():
if request.method == 'POST':
template = templates[request.form["template"]]
if request.form["template"] == "Food":
template["text2"]["string"] = datetime.now().strftime('%Y-%m-%d')
if request.form["template"] == "Remove by":
template["text2"]["string"] = (datetime.now() + timedelta(weeks=3)).strftime('%Y-%m-%d')
session["text1"] = template["text1"]
session["text2"] = template["text2"]
session["cut"] = template["cut"]

View file

@ -6,7 +6,7 @@
<form method="POST" action="/image" enctype="multipart/form-data">
<input type="file" name="image">
<input type="submit" value="Generate preview"><br>
Recommended image height = {{label_width}}, taller images will be scaled
Recommended image height = {{label_width}}, other sizes will be scaled
</form>
{% if info %}

View file

@ -8,6 +8,7 @@
<select name="template">
<option value="DNH">Do not hack</option>
<option value="Food">Food</option>
<option value="Remove by">Remove by</option>
</select>
<input type="submit" value="Apply">
</form>