fix: use local qr code generation to fix broken QR codes
All checks were successful
Build Docker / Build Image (push) Successful in 1m10s
All checks were successful
Build Docker / Build Image (push) Successful in 1m10s
This commit is contained in:
@@ -3,4 +3,5 @@ python-dotenv
|
|||||||
gunicorn
|
gunicorn
|
||||||
requests
|
requests
|
||||||
cloudflare
|
cloudflare
|
||||||
apscheduler
|
apscheduler
|
||||||
|
qrcode
|
||||||
20
server.py
20
server.py
@@ -1,4 +1,4 @@
|
|||||||
from flask import Flask, make_response, redirect, request, jsonify, render_template, send_from_directory
|
from flask import Flask, make_response, redirect, request, jsonify, render_template, send_from_directory, send_file
|
||||||
import os
|
import os
|
||||||
import dotenv
|
import dotenv
|
||||||
import requests
|
import requests
|
||||||
@@ -8,6 +8,8 @@ import render
|
|||||||
import payments
|
import payments
|
||||||
import threading
|
import threading
|
||||||
import account
|
import account
|
||||||
|
import qrcode
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
dotenv.load_dotenv()
|
dotenv.load_dotenv()
|
||||||
@@ -304,7 +306,7 @@ def payment_post():
|
|||||||
|
|
||||||
finalPrice = payment['ID']
|
finalPrice = payment['ID']
|
||||||
HNSaddress = payment['HNSaddress']
|
HNSaddress = payment['HNSaddress']
|
||||||
qr = f"<img src='https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl={HNSaddress}&choe=UTF-8' alt='QR Code' />"
|
qr = f"<img src='/qr/{HNSaddress}' style='width: 200px; height: 200px;'>"
|
||||||
|
|
||||||
# Center the QR code
|
# Center the QR code
|
||||||
qr = f"<div style='text-align: center;'>{qr}</div>"
|
qr = f"<div style='text-align: center;'>{qr}</div>"
|
||||||
@@ -313,6 +315,20 @@ def payment_post():
|
|||||||
responce.set_cookie('cart', '[]')
|
responce.set_cookie('cart', '[]')
|
||||||
return responce
|
return responce
|
||||||
|
|
||||||
|
@app.route('/qr/<path:path>')
|
||||||
|
def qr(path):
|
||||||
|
# Generate QR code
|
||||||
|
qr = qrcode.make(path)
|
||||||
|
|
||||||
|
# Save the QR code to a bytes buffer
|
||||||
|
buffer = BytesIO()
|
||||||
|
qr.save(buffer, format='PNG')
|
||||||
|
buffer.seek(0)
|
||||||
|
|
||||||
|
# Serve the image
|
||||||
|
return send_file(buffer, mimetype='image/png')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Promo routes
|
# Promo routes
|
||||||
@app.route('/promo')
|
@app.route('/promo')
|
||||||
|
|||||||
Reference in New Issue
Block a user