start
This commit is contained in:
20
backend/app/services/qrcodes.py
Normal file
20
backend/app/services/qrcodes.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import io
|
||||
|
||||
import qrcode
|
||||
|
||||
from app.core.config import get_settings
|
||||
|
||||
|
||||
def object_public_url(object_id) -> str:
|
||||
return f"{get_settings().public_base_url}/objects/{object_id}"
|
||||
|
||||
|
||||
def box_public_url(box_id) -> str:
|
||||
return f"{get_settings().public_base_url}/boxes/{box_id}"
|
||||
|
||||
|
||||
def generate_qr_png(data: str) -> bytes:
|
||||
img = qrcode.make(data, box_size=10, border=2)
|
||||
buffer = io.BytesIO()
|
||||
img.save(buffer, format="PNG")
|
||||
return buffer.getvalue()
|
||||
Reference in New Issue
Block a user