Make the back end accept n text fields
This commit is contained in:
parent
eb1056144c
commit
e41695e256
2 changed files with 40 additions and 42 deletions
80
app.py
80
app.py
|
|
@ -180,56 +180,54 @@ def text_form():
|
||||||
check_for_new_user(session)
|
check_for_new_user(session)
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
print(request.form)
|
line_count = int(request.form["lineCount"])
|
||||||
#session["text1"] = {
|
lines = []
|
||||||
# "string": request.form["string1"],
|
for i in range(0, line_count):
|
||||||
# "size": int(request.form["size1"]),
|
lines.append({
|
||||||
# "pos": int(request.form["pos1"]),
|
"string": request.form["text" + str(i)],
|
||||||
# "bold": "bold1" in request.form,
|
"size": int(request.form["size" + str(i)]),
|
||||||
#}
|
"pos": int(request.form["y_pos" + str(i)]),
|
||||||
#session["text2"] = {
|
"bold": False
|
||||||
# "string": request.form["string2"],
|
})
|
||||||
# "size": int(request.form["size2"]),
|
|
||||||
# "pos": int(request.form["pos2"]),
|
|
||||||
# "bold": "bold2" in request.form,
|
|
||||||
#}
|
|
||||||
|
|
||||||
## Clear previously saved font
|
# Clear previously saved font
|
||||||
#for font in session["fonts"]:
|
for font in session["fonts"]:
|
||||||
# session["fonts"][font]["selected"] = False
|
session["fonts"][font]["selected"] = False
|
||||||
|
|
||||||
## If an invalid font has been submitted, just default to the first one
|
# If an invalid font has been submitted, just default to the first one
|
||||||
#chosen_font = request.form["font"]
|
chosen_font = request.form["font"]
|
||||||
#if chosen_font in session["fonts"]:
|
if chosen_font in session["fonts"]:
|
||||||
# session["fonts"][chosen_font]["selected"] = True
|
session["fonts"][chosen_font]["selected"] = True
|
||||||
#else:
|
else:
|
||||||
# first_font = next(iter(session["fonts"]))
|
first_font = next(iter(session["fonts"]))
|
||||||
# session["fonts"][first_font]["selected"] = True
|
session["fonts"][first_font]["selected"] = True
|
||||||
|
|
||||||
## Select the first font that has been marked as selected
|
# Select the first font that has been marked as selected
|
||||||
#chosen_font = None
|
chosen_font = None
|
||||||
#for font in session["fonts"]:
|
for font in session["fonts"]:
|
||||||
# f = session["fonts"][font]
|
f = session["fonts"][font]
|
||||||
# if f["selected"]:
|
if f["selected"]:
|
||||||
# chosen_font = f
|
chosen_font = f
|
||||||
|
|
||||||
## If the font is still None, something has gone wrong
|
# If the font is still None, something has gone wrong
|
||||||
#if chosen_font is None:
|
if chosen_font is None:
|
||||||
# return
|
return
|
||||||
|
|
||||||
#message, status, img = gen_image(label_width, session["text1"], session["text2"], chosen_font)
|
print(chosen_font)
|
||||||
|
|
||||||
#if status == "Error":
|
message, status, img = gen_image(label_width, lines, chosen_font)
|
||||||
# session["text image path"] = None
|
|
||||||
# return render_text_template(message, "red")
|
|
||||||
|
|
||||||
#get_folder_path(session)
|
if status == "Error":
|
||||||
|
session["text image path"] = None
|
||||||
|
return render_text_template(message, "red")
|
||||||
|
|
||||||
#session["text image path"] = text_image_filename
|
get_folder_path(session)
|
||||||
#img.save(get_file_path(session, session["text image path"]))
|
|
||||||
|
|
||||||
#print()
|
session["text image path"] = text_image_filename
|
||||||
#print(session["text image path"])
|
img.save(get_file_path(session, session["text image path"]))
|
||||||
|
|
||||||
|
print()
|
||||||
|
print(session["text image path"])
|
||||||
|
|
||||||
return render_text_template(scrollDown = True)
|
return render_text_template(scrollDown = True)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,5 +67,5 @@ Text3 = {
|
||||||
"bold": False,
|
"bold": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
gen_image(200, [Text1, Text2, Text3], fonts()["CYBER"])[2].save("aaa.png")
|
#gen_image(200, [Text1, Text2, Text3], fonts()["CYBER"])[2].save("aaa.png")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue