{"id":22242313,"url":"https://github.com/marincervinschi/qr-flask","last_synced_at":"2026-04-08T21:32:27.976Z","repository":{"id":266053104,"uuid":"894025214","full_name":"MarinCervinschi/QR-flask","owner":"MarinCervinschi","description":"Dynamik QR Code is a Flask web app for generating and managing dynamic QR codes. Admins can update URLs without changing the QR code. Built for learning, it explores Flask, MySQL, and Docker while focusing on secure admin access and dynamic redirects.","archived":false,"fork":false,"pushed_at":"2024-12-02T14:47:46.000Z","size":594,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-30T09:41:51.210Z","etag":null,"topics":["actions","docker","docker-compose","dockerfile","environment","environment-variables","flask","flask-application","flask-web","mysql","mysql-database","pyhton","pytest","python3","schema","test","testing","workflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MarinCervinschi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-25T16:08:58.000Z","updated_at":"2024-12-02T14:49:22.000Z","dependencies_parsed_at":"2024-12-02T18:34:02.228Z","dependency_job_id":null,"html_url":"https://github.com/MarinCervinschi/QR-flask","commit_stats":null,"previous_names":["marincervinschi/qr-flask"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarinCervinschi%2FQR-flask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarinCervinschi%2FQR-flask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarinCervinschi%2FQR-flask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarinCervinschi%2FQR-flask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarinCervinschi","download_url":"https://codeload.github.com/MarinCervinschi/QR-flask/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245449416,"owners_count":20617185,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","docker","docker-compose","dockerfile","environment","environment-variables","flask","flask-application","flask-web","mysql","mysql-database","pyhton","pytest","python3","schema","test","testing","workflow"],"created_at":"2024-12-03T04:15:38.776Z","updated_at":"2026-04-08T21:32:27.970Z","avatar_url":"https://github.com/MarinCervinschi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"left\"\u003e\n  \u003cimg src=\"https://visitor-badge.laobi.icu/badge?page_id=MarinCervinschi.QR-Flask\u0026\"  /\u003e\n\u003c/div\u003e\n\n# QR Flask Project\n\n## Overview\n\nDynamik QR Code is a simple yet robust Flask-based web application designed as a learning project to explore modern web technologies and frameworks. The application generates dynamic QR codes that contain a URL, which can be updated without regenerating the QR code itself. This functionality makes it a practical tool for managing redirects while ensuring QR codes remain static for end users.\n\n### Key Features\n\n1. Dynamic QR Codes:\n   The QR codes generated by this app are tied to a URL stored on the server. Admins can update this URL, and the changes will reflect immediately without the need to regenerate the QR code.\n2. Admin-Only Access:\n   The app is designed solely for administrators. It includes private and protected pages, ensuring the functionality remains hidden from end users. The general public or users scanning the QR codes are unaware that their requests pass through this system before being redirected to the final destination.\n3. Learning-Focused:\n   This project serves as a practical platform to study and experiment with: - Flask Framework: For creating a Python-based web app. - Session Management: Secure handling of user sessions for admin pages. - Pytest and Coverage.py: For unit testing and code coverage. - MySQL Integration: For dynamic data storage and retrieval. - Docker and Docker Compose: To simplify deployment and ensure consistency across environments.\n\n4. Seamless User Experience:\n   Users scanning the QR codes will experience a direct redirection to the final link, unaware of the underlying intermediate step managed by the app.\n\n### Get Started\n\n- [Installation without setup](#installation-without-setup)\n  - [ON WINDOWS](#on-windows)\n  - [ON UNIX](#on-unix)\n- [Run Flask To Develop Locally](#run-flask-to-develop-locally)\n  - [Configuration](#configuration)\n  - [Usage](#usage)\n- [Testing](#testing)\n- [Deployment Structure](#deployment-structure)\n- [Deployment with Docker and Docker Compose](#deployment-with-docker-and-docker-compose)\n\n## Installation without setup\n\nClone the repository:\n\n```bash\ngit clone https://github.com/yourusername/QR-flask.git\ncd QR-flask\n```\n\n### ON WINDOWS\n\n- First, change permissions for the `start.bat` \u0026 `stop.bat` files:\n\n```powershell\nicacls start.bat /grant Everyone:F\n```\n\n- Then, run the `start.bat` file to start the application:\n\n```powershell\n.\\start.bat\n```\n\n- To stop the application, run the `stop.bat` file:\n\n```powershell\n.\\stop.bat\n```\n\n---\n\n### ON UNIX\n\n- First, change permissions for the `start.sh` \u0026 `stop.sh` files:\n\n```bash\nchmod +x start.sh\n```\n\n- Then, run the `start.sh` file to start the application:\n\n```bash\n./start.sh\n```\n\n- To stop the application, run the `stop.sh` file:\n\n```bash\n./stop.sh\n```\n\nOpen your web browser and go to `http://localhost:8000`.\n\n---\n\n\u003e **⚠️ Important Warning:**\n\u003e\n\u003e The `start.sh` and `start.bat` scripts create the `.flask.env` and `.mysql.env` files with default values. REMEMBER to change the default values in the `.env` files to secure your application.\n\n# Run Flask To Develop Locally\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/yourusername/QR-flask.git\n   cd QR-flask\n   ```\n\n2. Create a virtual environment:\n\n   ```bash\n   python3 -m venv venv\n   source venv/bin/activate\n   ```\n\n3. Install the dependencies:\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n## Configuration\n\n### Flask Environment Variables\n\nCreate a `.flask.env` file in the project root with the following content:\n\n**For local development (without Docker):**\n\n```bash\nFLASK_APP=app  # The app name\nFLASK_RUN_PORT=5000  # Port for the app\nFLASK_RUN_HOST=127.0.0.1  # App host for local development\nAPP_URL=http://127.0.0.1:5000  # URL for the app and QR code\nSECRET_KEY=your_secret_key  # Secret key for Flask\nPERMANENT_SESSION_LIFETIME=30  # Session lifetime in minutes\n```\n\n**For Docker deployment:**\n\n```bash\nFLASK_APP=app  # The app name\nFLASK_RUN_PORT=5000  # Port for the app (internal to container)\nFLASK_RUN_HOST=0.0.0.0  # App host (0.0.0.0 for Docker)\nAPP_URL=http://localhost:8000  # URL for the app and QR code\nSECRET_KEY=your_secret_key  # Secret key for Flask\nPERMANENT_SESSION_LIFETIME=30  # Session lifetime in minutes\n```\n\n\u003e **Note:** When using Docker, Flask must listen on `0.0.0.0` to accept connections from outside the container.\n\n### MySQL Environment Variables\n\nCreate a `.mysql.env` file in the project root with the following content:\n\n```bash\nMYSQL_ROOT_PASSWORD=root  # Root password\nMYSQL_HOST=qr-db  # Database host (e.g., service name in Docker or localhost)\nMYSQL_PORT=3306  # Database port\nMYSQL_PASSWORD=root  # User password\nMYSQL_DB=qr_db  # Database name\n```\n\nNote: These `.env` files are included in .`gitignore` to protect sensitive data.\n\n## Usage\n\n1. Run the Flask application:\n\n   ```bash\n   flask run\n   ```\n\n   or\n\n   ```bash\n   python run.py\n   ```\n\n2. Access the application:\n   Open your web browser and go to `http://127.0.0.1:5000`.\n\n3. To stop the Flask application, press `Ctrl+C` in the terminal.\n\n## Testing\n\n1. Run tests using pytest:\n\n   ```bash\n   python -m pytest\n   ```\n\n2. Generate a coverage report:\n\n   ```bash\n   coverage run -m pytest\n   coverage report\n   ```\n\n3. To generate an HTML coverage report:\n   ```bash\n   coverage html\n   ```\n   Open `htmlcov/index.html` in your web browser to view the report.\n\n## Deployment Structure\n\n```plaintext\n.\n└── docker-compose.yml\n    ├── qr-db:\n    │   └── mysql:8.4\n    └── qr-app:\n        ├── build .\n        └── depends_on:\n            └── qr-db\n```\n\n## Deployment with Docker and Docker Compose\n\n1. Build and start the containers:\n\n   ```bash\n   docker-compose up --build -d\n   ```\n\n   The `-d` flag runs the containers in the background.\n\n2. Open your web browser and go to `http://localhost:8000`.\n\n3. To stop the containers, run:\n\n   ```bash\n   docker-compose down -v\n   ```\n\n   The `-v` flag removes the volumes associated with the containers.\n\n4. To view the logs of a specific service, run:\n\n   ```bash\n   docker-compose logs \u003cservice_name\u003e\n   ```\n\n5. To run commands inside a running container, use:\n\n   ```bash\n   docker-compose exec \u003cservice_name\u003e \u003ccommand\u003e\n   ```\n\n6. To connect to the MySQL database, run:\n\n   ```bash\n   docker-compose exec qr-db mysql -u root -p qr_db\n   ```\n\n   Enter the password when prompted.\n\n7. To view the tables in the database, run:\n   ```bash\n   mysql\u003e SHOW TABLES;\n   ```\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarincervinschi%2Fqr-flask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarincervinschi%2Fqr-flask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarincervinschi%2Fqr-flask/lists"}