Wednesday, 16 January 2019

Generate QRcode using Python

Generate QRcode using Python

Step 1: Download and Install Python

Step 2: Open CMD prompt and run the following command to install flask and pyqrcode module

>> pip install flask
>> pip install pyqrcode
Step 3: Open the new text document and place the following code

import io

from flask import Flask, send_file, request

import pyqrcode


app=Flask(__name__)


@app.route('/qrcode', methods=['GET'])
def search_data():
    query = request.args.get('query', '')
    qr = pyqrcode.create(query)
    qr.png(query+'.png', scale=3)
    with open(query+'.png', 'rb') as bites:
        return send_file(
                     io.BytesIO(bites.read()),
                     attachment_filename=query+'.png',
                     mimetype='image/png'
               )

if __name__ == "__main__":
    app.run(debug=True)  

Step 4: Save the file in .py format. (e.g. file_nm.py)

Step 5: Deploy this python web app in Restful web service.

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. QR Codes give you an opportunity to talk to your customers one-on-one about the outfit they are viewing and boost sales.

    QR Generator
    QR Code Generator
    QR Code
    QR code online generator
    QR code Maker
    QR code scanner

    ReplyDelete