Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QR Code Generator (Python)

A minimal, production-friendly Python project to generate QR codes from text or URLs.

Folder structure

qr/
├─ pyproject.toml          # Project metadata and dependencies
├─ src/
│  └─ qrgen/
│     ├─ __init__.py
│     ├─ generate.py       # Library functions
│     └─ cli.py            # CLI entrypoint `qrgen`
├─ tests/
│  └─ test_generate.py
├─ .gitignore
└─ README.md

Setup

python3 -m venv .venv
source .venv/bin/activate 

# install in editable/development mode (and dependencies)
pip install -e .

# or install dependencies directly
# pip install qrcode[pil]

Usage

  • Library:
from qrgen import save_qr

save_qr("https://example.com", "out.png")
  • CLI:
qrgen "https://example.com" -o out.png --error-correction H --box-size 8

Output

The output is a PNG image file containing the QR code.

  • Default location: If you don't specify -o, the file is saved as qr.png in your current working directory
  • Custom location: Use -o path/to/file.png to save anywhere you want
  • After running: The CLI prints the full path where the file was saved, e.g.:
    Saved QR to /Users/owner/Desktop/Django/qr/qr.png
    

To view the QR code:

  1. Open the PNG file with any image viewer (Photos app, Preview on Mac, etc.)
  2. Scan it with any QR code scanner app on your phone
  3. Open it in a web browser to see the image

Example:

# Generate QR code (saves to qr.png in current directory)
qrgen "Hello World"

# Generate and save to a specific location
qrgen "https://example.com" -o ~/Desktop/my_qr.png

Run tests

pip install pytest
pytest

Django integration (optional)

If you prefer this as a Django app inside your existing project:

  • Create a Django app (e.g., python manage.py startapp qrcodes)
  • Add a view that calls save_qr and returns the image via FileResponse
  • Wire up a URL like /qr/?data=... and generate on-the-fly

This repository remains framework-agnostic so you can use it from Django, Flask, or CLI.

About

QR Scanner code maker by using python

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages