{"id":15083574,"url":"https://github.com/shohail-dev/2-tier-flask-application","last_synced_at":"2026-01-06T23:43:25.202Z","repository":{"id":251426607,"uuid":"837382871","full_name":"shohail-DeV/2-Tier-Flask-Application","owner":"shohail-DeV","description":"This is a simple Flask app that interacts with a MySQL database. The app allows users to submit messages, which are then stored in the database and displayed on the frontend.","archived":false,"fork":false,"pushed_at":"2024-08-02T21:03:00.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T22:16:45.699Z","etag":null,"topics":["aws-ec2","docker","jenkins","k8s-cluster","k8s-deployment","kubeadm"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shohail-DeV.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-08-02T20:59:56.000Z","updated_at":"2024-08-02T21:07:48.000Z","dependencies_parsed_at":"2024-08-02T23:53:50.485Z","dependency_job_id":null,"html_url":"https://github.com/shohail-DeV/2-Tier-Flask-Application","commit_stats":null,"previous_names":["shohail-dev/2-tier-flask-application"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shohail-DeV%2F2-Tier-Flask-Application","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shohail-DeV%2F2-Tier-Flask-Application/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shohail-DeV%2F2-Tier-Flask-Application/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shohail-DeV%2F2-Tier-Flask-Application/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shohail-DeV","download_url":"https://codeload.github.com/shohail-DeV/2-Tier-Flask-Application/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246106691,"owners_count":20724401,"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":["aws-ec2","docker","jenkins","k8s-cluster","k8s-deployment","kubeadm"],"created_at":"2024-09-25T06:02:46.303Z","updated_at":"2026-01-06T23:43:25.136Z","avatar_url":"https://github.com/shohail-DeV.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":" \n# Flask App with MySQL Docker Setup\n\nThis is a simple Flask app that interacts with a MySQL database. The app allows users to submit messages, which are then stored in the database and displayed on the frontend.\n\n## Prerequisites\n\nBefore you begin, make sure you have the following installed:\n\n- Docker\n- Git (optional, for cloning the repository)\n\n## Setup\n\n1. Clone this repository (if you haven't already):\n\n   ```bash\n   git clone https://github.com/your-username/your-repo-name.git\n   ```\n\n2. Navigate to the project directory:\n\n   ```bash\n   cd your-repo-name\n   ```\n\n3. Create a `.env` file in the project directory to store your MySQL environment variables:\n\n   ```bash\n   touch .env\n   ```\n\n4. Open the `.env` file and add your MySQL configuration:\n\n   ```\n   MYSQL_HOST=mysql\n   MYSQL_USER=your_username\n   MYSQL_PASSWORD=your_password\n   MYSQL_DB=your_database\n   ```\n\n## Usage\n\n1. Start the containers using Docker Compose:\n\n   ```bash\n   docker-compose up --build\n   ```\n\n2. Access the Flask app in your web browser:\n\n   - Frontend: http://localhost\n   - Backend: http://localhost:5000\n\n3. Create the `messages` table in your MySQL database:\n\n   - Use a MySQL client or tool (e.g., phpMyAdmin) to execute the following SQL commands:\n   \n     ```sql\n     CREATE TABLE messages (\n         id INT AUTO_INCREMENT PRIMARY KEY,\n         message TEXT\n     );\n     ```\n\n4. Interact with the app:\n\n   - Visit http://localhost to see the frontend. You can submit new messages using the form.\n   - Visit http://localhost:5000/insert_sql to insert a message directly into the `messages` table via an SQL query.\n\n## Cleaning Up\n\nTo stop and remove the Docker containers, press `Ctrl+C` in the terminal where the containers are running, or use the following command:\n\n```bash\ndocker-compose down\n```\n\n## To run this two-tier application using  without docker-compose\n\n- First create a docker image from Dockerfile\n```bash\ndocker build -t flaskapp .\n```\n\n- Now, make sure that you have created a network using following command\n```bash\ndocker network create twotier\n```\n\n- Attach both the containers in the same network, so that they can communicate with each other\n\ni) MySQL container \n```bash\ndocker run -d \\\n    --name mysql \\\n    -v mysql-data:/var/lib/mysql \\\n    --network=twotier \\\n    -e MYSQL_DATABASE=mydb \\\n    -e MYSQL_ROOT_PASSWORD=admin \\\n    -p 3306:3306 \\\n    mysql:5.7\n\n```\nii) Backend container\n```bash\ndocker run -d \\\n    --name flaskapp \\\n    --network=twotier \\\n    -e MYSQL_HOST=mysql \\\n    -e MYSQL_USER=root \\\n    -e MYSQL_PASSWORD=admin \\\n    -e MYSQL_DB=mydb \\\n    -p 5000:5000 \\\n    flaskapp:latest\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshohail-dev%2F2-tier-flask-application","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshohail-dev%2F2-tier-flask-application","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshohail-dev%2F2-tier-flask-application/lists"}