Spaces:
Running on Zero
Running on Zero
Download scripts/generer_qr.py from PythonMindset/guindima-ai: direct link, hf CLI and curl.
- Browser
- Download file 1.47 kB
-
https://huggingface.co/spaces/PythonMindset/guindima-ai/resolve/main/scripts/generer_qr.py
- Command line
-
hf download hf://spaces/PythonMindset/guindima-ai/scripts/generer_qr.py
-
curl -L -o generer_qr.py https://huggingface.co/spaces/PythonMindset/guindima-ai/resolve/main/scripts/generer_qr.py
1.47 kB
| """Régénère le QR de la section accueil (assets/qr_guindima.svg et .png), hors réseau. | |
| Lot D1 : le QR doit ouvrir le lien direct du Space (LIEN_APP, | |
| https://pythonmindset-guindima-ai.hf.space), pas la page huggingface.co/spaces/… | |
| dont le cadre fait trembler la page sur téléphone. | |
| Il faut la bibliothèque « segno » (celle qui avait produit le QR fourni), non | |
| installée dans le .venv au 01/12/2026. Une fois installée (une seule fois, | |
| avec réseau) : python -m pip install segno | |
| Usage (PowerShell) : | |
| $env:PYTHONIOENCODING='utf-8' | |
| .\\.venv\\Scripts\\python.exe scripts\\generer_qr.py | |
| """ | |
| from __future__ import annotations | |
| import sys | |
| from pathlib import Path | |
| RACINE = Path(__file__).resolve().parents[1] | |
| sys.path.insert(0, str(RACINE / "src")) | |
| from app.partage import LIEN_APP # noqa: E402 | |
| SVG = RACINE / "assets" / "qr_guindima.svg" | |
| PNG = RACINE / "assets" / "qr_guindima.png" | |
| def main() -> None: | |
| try: | |
| import segno | |
| except ImportError: | |
| print("segno n'est pas installé : python -m pip install segno") | |
| sys.exit(1) | |
| # Correction d'erreur « M » : lisible même un peu abîmé, sans grossir le QR. | |
| qr = segno.make(LIEN_APP, error="m", micro=False) | |
| qr.save(str(SVG), scale=8, border=2, dark="#0B2E1A", light=None) | |
| qr.save(str(PNG), scale=12, border=2, dark="#0B2E1A", light="#FFFFFF") | |
| print(f"QR régénéré pour {LIEN_APP} : {SVG.name}, {PNG.name}") | |
| if __name__ == "__main__": | |
| main() | |