1👍
Just point the new src
of your image at the your python script. Assuming your script returns an image.
<html>
<body>
<img id="qrcode_container" src="assets/filler_image.png" width="35%">
<p></p>
<button onclick="document.getElementById('qrcode_container').src=
'***PATH TO PYTHON SCRIPT HERE***'">Generate Code</button>
</body>
1👍
There can be a hacky solution where you can get Python and Javascript to communicate, but the best solution here, would be to implement a single endpoint and service requests in Python.
Yes, using Django or Flask would be an overkill, but using something like Falcon should suffice. Below is a sample Falcon program that would suffice.
# sample.py
import falcon
import json
class QRResource:
def on_post(self, req, resp, text):
# generate QR code at a destination
output = {
'path': 'path accessable by user',
'uuid': "UUID HERE"
}
resp.body = json.dumps(quote)
api = falcon.API()
api.add_route('/qr', QRResource())
- [Answered ]-Can't load statics, Django rest_framework on Apache, Windows
- [Answered ]-How can I create simple Django chat based on WebSockets with PostgreSQL database?
Source:stackexchange.com