From 0cdf3f4a98088a18b841c0556f9fe77c1db89ed6 Mon Sep 17 00:00:00 2001 From: Sam Willcocks Date: Fri, 18 Aug 2023 14:37:01 +0200 Subject: [PATCH] Add counts --- main.py | 21 ++++++++++++--------- templates/index.html | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index 8c3c09a..c5f0de7 100644 --- a/main.py +++ b/main.py @@ -76,15 +76,18 @@ async def print(): subprocess.run(f"convert {png_filename} -resize 696x -background white -alpha remove -alpha off -monochrome -threshold 20% {png_filename}", shell=True, check=True) #if not os.path.exists(quad_png_filename): # subprocess.run("magick -size 696x xc:white ({png_filename} -resize 50%x) - printit(png_filename) - cur.execute("""INSERT OR REPLACE INTO counts(what, count) - VALUES (:what, - COALESCE( - (SELECT count FROM counts - WHERE what=:what), - 0) + 1); - """, dict(what=lol)) - db.commit() + for _ in range(int((await request.form)["count"])): + printit(png_filename) + cur.execute("""INSERT OR REPLACE INTO counts(what, count) + VALUES (:what, + COALESCE( + (SELECT count FROM counts + WHERE what=:what), + 0) + 1); + """, dict(what=lol)) + db.commit() + with open("counts.txt", "a") as f: + f.write(f"{lol}\n") return redirect("/") if __name__ == "__main__": diff --git a/templates/index.html b/templates/index.html index 6def229..6365d0e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -35,6 +35,7 @@ {{ counts.get(w.name, 0) }}
+