This project is a Link Shortener and QR Code Generator, designed to simplify sharing links and text. The web application shortens URLs and generates QR codes for any input, providing a seamless way to handle and share digital information.
The project can be accessed live at:
Link Shortener and QR Code Generator
- URL Shortening: Automatically shortens long URLs for easy sharing.
- QR Code Generation: Converts text or links into scannable QR codes.
- Error Handling: Ensures inputs do not exceed 256 characters and validates URLs.
- Copy & Download Functionality:
- Copy shortened URLs with one click.
- Download generated QR codes as PNG images.
- Responsive Design: Mobile and desktop-friendly UI for an optimal user experience.
- Enter any URL or text in the input field.
- Ensure the text length is within 256 characters.
- Press the Generate button.
- If the input is a valid URL, it will be shortened.
- A QR code for the shortened URL or text will be generated.
- Copy the shortened URL by clicking the Copy button.
- Download the QR code by clicking the Download QR Code button.
- Shorten a URL: Input
https://example.com/very/long/url
to get a shortened version likehttps://tinyurl.com/abc123
. - Generate a QR Code: Input "Hello, World!" to create a scannable QR code containing the text.
-
URL Validation:
def is_valid_url(url): """Check if the given string is a valid URL.""" result = urlparse(url) return all([result.scheme, result.netloc])
-
Shorten URLs using TinyURL API:
def shorten_url(url): s = pyshorteners.Shortener() return s.tinyurl.short(url)
-
QR Code Generation:
qr = qrcode.QRCode(version=1, box_size=10, border=2) qr.add_data(data) qr.make(fit=True) img = qr.make_image(fill_color="black", back_color="white")
-
Dynamic Input Validation:
document.getElementById('qrInput').addEventListener('input', function() { // Hides containers for empty input });
-
Copy Shortened URL:
function copyUrl() { navigator.clipboard.writeText(shortUrl.value).then(() => alert("URL copied!")); }
-
Lazy Loading Background:
const bgImage = new Image(); bgImage.src = "path/to/bg.png"; bgImage.onload = () => body.style.backgroundImage = `url('${bgImage.src}')`;
-
Clone the Repository
git clone https://github.com/ivin-titus/link-shortener-qr-generator.git cd link-shortener-qr-generator
-
Install Dependencies
pip install flask qrcode pyshorteners
-
Run the Application
python app.py
-
Access Locally
Openhttp://127.0.0.1:5000/
in your browser.
This project is open-source and free to use under the MIT License. You are free to reuse and redistribute the code with proper attribution.
© 2024 Ivin Titus. All rights reserved.