|
|
- #!/bin/python3
- from flask import Flask, render_template
- import qrcode
- import os
- app = Flask(__name__, template_folder="templates")
-
- @app.route('/')
- def index():
- # Generate QR code
- qr = qrcode.QRCode(version=1, box_size=10, border=5)
- qr.add_data("localhost") # You can replace this URL with any link you want
- qr.make(fit=True)
- qr_img = qr.make_image(fill_color="black", back_color="white")
- qr_img = qr.make_image(fill_color="black", back_color="white")
- qr_img.save("/home/anpham/Projects/virtual-bussiness-card/static/qr_code.png") # Save QR code image
- return render_template('index.html')
-
- if __name__ == '__main__':
- app.run(debug=True)
-
|