I have a python script that generates a QR code (saved as a .png) and a webpage. I am trying to make a javascript button trigger the python script to generate an image, and replace the filler image I have on the HTML page.
Process:
User clicks button --> python script runs --> python returns QR code to webpage
Heres the sample HTML:
<html>
<body>
<img id="qrcode_container" src="assets/filler_image.png" width="35%">
<p></p>
<button onclick="document.getElementById('qrcode_container').src=
'assets/sampleQR.png'">Generate Code</button>
</body>
</html>
But this simply replaces the image with a pre-made one.
Here is the python code:
import pyqrcode, uuid, png
uuid_raw = uuid.uuid4()
uuid_string = str(uuid_raw)
print(real_code)
qrImage = pyqrcode.create(uuid_string)
qrImage.png(uuid_string+'.png', scale=16)
So ideally I would like to have the button on the webpage trigger the script to run, then replace the filler image on the webpage with the new QR code, as well as return the UUID. I've checked out frameworks like Django and Flask, but they seem overkill for a webpage I'm only using to generate an image. Should I use PHP to trigger the event?