Add counts
This commit is contained in:
parent
22ecb7c4ca
commit
0cdf3f4a98
21
main.py
21
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)
|
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):
|
#if not os.path.exists(quad_png_filename):
|
||||||
# subprocess.run("magick -size 696x xc:white ({png_filename} -resize 50%x)
|
# subprocess.run("magick -size 696x xc:white ({png_filename} -resize 50%x)
|
||||||
printit(png_filename)
|
for _ in range(int((await request.form)["count"])):
|
||||||
cur.execute("""INSERT OR REPLACE INTO counts(what, count)
|
printit(png_filename)
|
||||||
VALUES (:what,
|
cur.execute("""INSERT OR REPLACE INTO counts(what, count)
|
||||||
COALESCE(
|
VALUES (:what,
|
||||||
(SELECT count FROM counts
|
COALESCE(
|
||||||
WHERE what=:what),
|
(SELECT count FROM counts
|
||||||
0) + 1);
|
WHERE what=:what),
|
||||||
""", dict(what=lol))
|
0) + 1);
|
||||||
db.commit()
|
""", dict(what=lol))
|
||||||
|
db.commit()
|
||||||
|
with open("counts.txt", "a") as f:
|
||||||
|
f.write(f"{lol}\n")
|
||||||
|
|
||||||
return redirect("/")
|
return redirect("/")
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
{{ counts.get(w.name, 0) }}
|
{{ counts.get(w.name, 0) }}
|
||||||
</div>
|
</div>
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
|
<input type="number" min="1" max="10" value="1" name="count">
|
||||||
<button type="submit" name="w" value="{{ w.name }}">Print</button>
|
<button type="submit" name="w" value="{{ w.name }}">Print</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue