Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Added a QR Code Generator in Python #104

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions System-Automation-Scripts/qrGenerator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# qrGenerator

- A Python Script that asks the user to input an URL or any string of characters and then coverts it to a QR code as the name of the URL domain, saved locally in the current working directory or as specified by the user.
- Also, if the program finds an existing QR with the same filename, it creates a new one with a random number at the end of the filename.
- Can be used either in the Command Line or within the Python IDE
20 changes: 20 additions & 0 deletions System-Automation-Scripts/qrGenerator/qrGenerator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os
import qrcode
from sys import argv
from urllib.parse import urlparse
import random

if len(argv)==2:
url = str(argv[1])
else:
url = input("Enter an URL to Encode in QR: ")

path = ((urlparse(url)).netloc)
image = qrcode.make(url)

if os.path.exists(f"{path}.png"):
path = path + str(random.randint(0,10000))

image.save(f"{path}.png", "PNG")
file_path = os.path.abspath(path)
print("File saved to:", file_path)