Skip to content

String to QR Code

Setup a webapp to generate QR code. Demo available at https://ez-qrcode-generator.herokuapp.com/

The Design

One liner:

  • the webapp should allow users to type in some text and convert text to QR code

UI cannot be simpler:

  • A label
  • A text input field
  • A submit button

The Technology

Life is short, use Python

The Implementation

See GitHub repo.

  • python-qrcode does all the dirty work to generate QR code from string

  • flask serves a webapp with only one endpoint, it returns the form upon GET and displays the QR code image upon POST

  • the flask snippet shows how to avoid creating a temp file for the image

The Deploy

Deploying this simple MVP to Heroku is easy.

runtime.txt

python-3.7.3 specifies the python version

requirements.txt

pip freeze the dependencies to a requirements.txt file

Procfile

Create a Procfile to declare it as a web app served by gunicorn web: gunicorn app:app --log-file=-

See Getting Started on Heroku with Python for more info.

The Demo

Demo available at ez-qrcode-generator.herokuapp.com

Interesting use case includes:

Set up wifi network/password

Use the template WIFI:T:WPA;S:<network>;P:<password>;; where <network> and <password> are your network's name and password respectively