From 6193ad90f75c85ceb738142c68c19e6c15c0080b Mon Sep 17 00:00:00 2001 From: Arhaan Siddiquee <85843373+Arhaan-Siddiquee@users.noreply.github.com> Date: Mon, 21 Oct 2024 21:42:14 +0530 Subject: [PATCH 1/6] Create QR Code Generator --- QR Code Generator | 1 + 1 file changed, 1 insertion(+) create mode 100644 QR Code Generator diff --git a/QR Code Generator b/QR Code Generator new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/QR Code Generator @@ -0,0 +1 @@ + From 3328ae7eb2f9a10766737bb058d9823ed4207fc2 Mon Sep 17 00:00:00 2001 From: Arhaan Siddiquee <85843373+Arhaan-Siddiquee@users.noreply.github.com> Date: Mon, 21 Oct 2024 21:43:02 +0530 Subject: [PATCH 2/6] Delete QR Code Generator --- QR Code Generator | 1 - 1 file changed, 1 deletion(-) delete mode 100644 QR Code Generator diff --git a/QR Code Generator b/QR Code Generator deleted file mode 100644 index 8b13789..0000000 --- a/QR Code Generator +++ /dev/null @@ -1 +0,0 @@ - From 89bbacd08491bcc893034083a5c4576bb066d1c5 Mon Sep 17 00:00:00 2001 From: Arhaan Siddiquee <85843373+Arhaan-Siddiquee@users.noreply.github.com> Date: Mon, 21 Oct 2024 21:43:40 +0530 Subject: [PATCH 3/6] Create QR Code Generator --- QR Code Generator | 1 + 1 file changed, 1 insertion(+) create mode 100644 QR Code Generator diff --git a/QR Code Generator b/QR Code Generator new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/QR Code Generator @@ -0,0 +1 @@ + From 7b599e310a50de2b650569b570a8813d1dcaecfc Mon Sep 17 00:00:00 2001 From: Arhaan Siddiquee <85843373+Arhaan-Siddiquee@users.noreply.github.com> Date: Mon, 21 Oct 2024 21:43:54 +0530 Subject: [PATCH 4/6] Delete QR Code Generator --- QR Code Generator | 1 - 1 file changed, 1 deletion(-) delete mode 100644 QR Code Generator diff --git a/QR Code Generator b/QR Code Generator deleted file mode 100644 index 8b13789..0000000 --- a/QR Code Generator +++ /dev/null @@ -1 +0,0 @@ - From 9f8c6a1f6081ee9b58f39edc34769ffcfab0e26d Mon Sep 17 00:00:00 2001 From: siddi Date: Mon, 21 Oct 2024 22:05:54 +0530 Subject: [PATCH 5/6] qr code GENERATOR --- QR CODE GENERATOR/app.py | 44 +++++++++++++++ QR CODE GENERATOR/static/styles.css | 75 ++++++++++++++++++++++++++ QR CODE GENERATOR/templates/index.html | 38 +++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 QR CODE GENERATOR/app.py create mode 100644 QR CODE GENERATOR/static/styles.css create mode 100644 QR CODE GENERATOR/templates/index.html diff --git a/QR CODE GENERATOR/app.py b/QR CODE GENERATOR/app.py new file mode 100644 index 0000000..4d02ab1 --- /dev/null +++ b/QR CODE GENERATOR/app.py @@ -0,0 +1,44 @@ +from flask import Flask, render_template, request, send_file +import barcode +from barcode.writer import ImageWriter +from io import BytesIO +import qrcode + +app = Flask(__name__) + +@app.route('/') +def index(): + return render_template('index.html') + +@app.route('/generate', methods=['POST']) +def generate_barcode(): + code = request.form['code'] + barcode_type = request.form['barcode_type'] + color = request.form.get('color', 'black') + + if barcode_type == "qrcode": + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + qr.add_data(code) + qr.make(fit=True) + img = qr.make_image(fill_color=color, back_color="white") + buffer = BytesIO() + img.save(buffer, format="PNG") + buffer.seek(0) + return send_file(buffer, mimetype='image/png', as_attachment=True, download_name='qrcode.png') + else: + barcode_format = barcode.get_barcode_class(barcode_type) + generated_barcode = barcode_format(code, writer=ImageWriter()) + options = {'foreground': color} + buffer = BytesIO() + generated_barcode.write(buffer, options=options) + buffer.seek(0) + + return send_file(buffer, mimetype='image/png', as_attachment=True, download_name='barcode.png') + +if __name__ == '__main__': + app.run(debug=True) \ No newline at end of file diff --git a/QR CODE GENERATOR/static/styles.css b/QR CODE GENERATOR/static/styles.css new file mode 100644 index 0000000..f57b593 --- /dev/null +++ b/QR CODE GENERATOR/static/styles.css @@ -0,0 +1,75 @@ +@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap'); + +body { + background: linear-gradient(135deg, #000000, #6a0dad, #000000); + min-height: 100vh; + display: flex; + align-items: center; + justify-content: center; + margin: 0; + font-family: 'Press Start 2P', cursive; +} + +.container { + width: 700px; + height: 500px; + margin: 0 auto; + padding: 20px; + background: linear-gradient(135deg, #000000, #6a0dad, #000000); + box-shadow: 5px 5px 17px 17px rgba(255, 255, 255, 0.5); + border-radius: 12px; + color: #ffffff; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + font-family: 'Press Start 2P', cursive; +} + +h1 { + color: #ffffff; + text-align: center; + margin-bottom: 20px; + font-family: 'Press Start 2P', cursive; +} + +.form-label { + font-weight: bold; + color: #ffffff; + margin-bottom: 10px; + font-family: 'Press Start 2P', cursive; +} + +input[type="color"] { + width: 100%; + height: 40px; + border-radius: 5px; + padding: 0; + cursor: pointer; + border: none; + background: transparent; + box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); +} + +input[type="color"]::-webkit-color-swatch-wrapper { + padding: 0; + border-radius: 5px; +} + +input[type="color"]::-webkit-color-swatch { + border: none; + border-radius: 5px; +} + +.btn-primary { + background-color: #6a0dad; + border-color: #6a0dad; + margin-top: 20px; + border-width: 2px; + font-family: 'Press Start 2P', cursive; +} + +.btn-primary:hover { + background-color: #5c0b8e; + border-color: #5c0b8e; +} \ No newline at end of file diff --git a/QR CODE GENERATOR/templates/index.html b/QR CODE GENERATOR/templates/index.html new file mode 100644 index 0000000..59ed3ca --- /dev/null +++ b/QR CODE GENERATOR/templates/index.html @@ -0,0 +1,38 @@ + + + + + + Barcode and QR Code Generator + + + + + + + +
+

Barcode & QR Code Generator

+
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file From 888dc35ecdbbdd27e18b33a038acf83efa711e29 Mon Sep 17 00:00:00 2001 From: siddi Date: Mon, 21 Oct 2024 22:16:03 +0530 Subject: [PATCH 6/6] added README --- QR CODE GENERATOR/README.md | 65 +++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 QR CODE GENERATOR/README.md diff --git a/QR CODE GENERATOR/README.md b/QR CODE GENERATOR/README.md new file mode 100644 index 0000000..d113855 --- /dev/null +++ b/QR CODE GENERATOR/README.md @@ -0,0 +1,65 @@ +# Barcode Generator + +This project is a web-based application that allows users to generate barcodes and QR codes. The application is built using Flask (Python) for the backend, and HTML/CSS for the frontend. Users can input text and select a barcode type to generate and download the corresponding barcode or QR code image. + +Screenshot of the Barcode Generator + +## Features + +- **Generate Barcodes**: Supports different types of barcodes including QR Code, Code 128, EAN-13, and UPC-A. +- **Customizable Colors**: Users can select the color of the barcode or QR code. +- **Image Download**: The generated barcode or QR code can be downloaded directly as a PNG image. + +## Technologies Used + +- **Python**: Backend logic and barcode generation using the Flask framework. +- **Flask**: Web framework used to serve the application. +- **HTML/CSS**: Frontend interface design. +- **qrcode**: Python library for generating QR codes. +- **python-barcode**: Python library for generating barcodes. + +## Installation and Setup + +### Prerequisites + +- Python 3.x +- pip (Python package manager) + +### Installation Steps + +1. **Clone the Repository**: + ```bash + git clone https://github.com/yourusername/barcode-generator.git + cd barcode-generator +2. **Install Dependencies: Install the required Python packages using pip:** + + ```bash + pip install flask qrcode[pil] python-barcode Pillow +3. **Run the Application: Start the Flask server:** + + ```bash + python app.py +4. **Access the Application:** Open your web browser and navigate to http://127.0.0.1:5000/ to use the barcode generator. + +## Usage + +- **Input the Code:** Enter the text or code that you want to generate as a barcode or QR code. +- **Select Barcode Type:** Choose from QR Code, Code 128, EAN-13, or UPC-A. +- **Choose a Color:** Pick a color for the barcode or QR code using the color picker. +- **Generate and Download:** Click the "Generate Barcode" button. The barcode or QR code will be generated and downloaded as a PNG image. +## File Structure +```plaintext + barcode-generator/ + │ + ├── templates/ + │ └── index.html # HTML file for the frontend interface + │ + ├── app.py # Main application file containing Flask routes and logic + │ + └── README.md # This README file +``` +## Troubleshooting +- **Missing Libraries:** Ensure all required Python packages are installed using pip install -r requirements.txt. +- **Port Issues:** If the default port 5000 is already in use, change the port in app.py by updating the app.run() function. +## Contributing +Contributions are welcome! If you find any issues or have ideas for improvements, feel free to create an issue or submit a pull request. \ No newline at end of file