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 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