{"id":21251592,"url":"https://github.com/ntshvicky/flask-mysql-mvc","last_synced_at":"2026-04-13T22:32:40.521Z","repository":{"id":205856862,"uuid":"715258237","full_name":"ntshvicky/Flask-Mysql-MVC","owner":"ntshvicky","description":"An example of Python Flask API with a kind of MVC design with Employee Data Example with MySql Client","archived":false,"fork":false,"pushed_at":"2023-12-28T09:17:06.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T05:26:34.615Z","etag":null,"topics":["flask","flask-rest-api","mysql","python"],"latest_commit_sha":null,"homepage":"","language":"Python","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/ntshvicky.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":"2023-11-06T19:28:49.000Z","updated_at":"2024-10-18T01:16:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"477a8fea-fa8a-4755-b18a-20ebc24a3300","html_url":"https://github.com/ntshvicky/Flask-Mysql-MVC","commit_stats":null,"previous_names":["ntshvicky/flask-mysql-mvc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ntshvicky/Flask-Mysql-MVC","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntshvicky%2FFlask-Mysql-MVC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntshvicky%2FFlask-Mysql-MVC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntshvicky%2FFlask-Mysql-MVC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntshvicky%2FFlask-Mysql-MVC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ntshvicky","download_url":"https://codeload.github.com/ntshvicky/Flask-Mysql-MVC/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntshvicky%2FFlask-Mysql-MVC/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31774028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T20:17:16.280Z","status":"ssl_error","status_checked_at":"2026-04-13T20:17:08.216Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["flask","flask-rest-api","mysql","python"],"created_at":"2024-11-21T03:42:49.261Z","updated_at":"2026-04-13T22:32:40.505Z","avatar_url":"https://github.com/ntshvicky.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# generate flask secret key and add on .env\npython3 -c 'import secrets, base64;print(base64.urlsafe_b64encode(secrets.token_bytes(32)))'\n\n\n# to push and pull\nfind . | grep -E \"(__pycache__|\\.pyc|\\.pyo$)\" | xargs rm -rf\ngit add .\ngit commit -m \"okay\"\ngit push origin master\n\n# for pdf printing install wkhtmltopdf\nhttps://computingforgeeks.com/install-wkhtmltopdf-on-ubuntu-debian-linux/\n\n\n# deploye api in Ubuntu server (aprox same in all Linux)\n## Install Nginx - apt-get install nginx\n## Install wkhtmltopdf - as above URL\n## Install database mysql - \n1. apt-get install mysql-server \n2. setup using - sudo mysql_secure_installation\n3. create database by executing sql file - mysql -u root -p \u003c testdb2.sql\n## Setup project\n1. Download or clone your project\n2. inside the project directory create python virtual environment\n    a) python3 -m virtualenv env\n    b) source env/bin/activate\n3. install all dependencies - \n    pip3 install -r requirements.txt\n    pip3 install 'pydantic[email]' # if required\n    pip3 install 'flask-openapi3[yaml]' # if required\n4. create service file same as api.service in /etc/systemd/system based on your environment\n5. start service - systmctl start api.service\n6. add service to startup - systmctl enable api.service\n7. check if service is running - systemctl status api.service\n8. Listen this service to nginx web server\n    a) add a file like \"api\" in /etc/nginx/sites-available\n    b) Link this file to nginx enable directory - /etc/nginx/sites-enabled\n        sudo ln -s /etc/nginx/sites-available/api /etc/nginx/sites-enabled\n9. check if service is running or there is no error on deployment - nginx -t\n10. start nginx web server - systmctl restart nginx\n11. Run in IP\n\n\nIf you are using cloud server like ubuntu or aws, dont forget to open 80 port or port you required to listen nginx for this api\n\n# or setup via docker\n## How to run docker and docker setup\n1. Create Dockerfile in app folder\n2. other project required files\n3. create a docker-compose.yml in root folder, where you have to execute docker-compose command\n4. create a nginx.conf file with nginx configuartion to run app in webserver \n    This is important to run app in any webserver so you can execute all running instances in one port with reverse proxy setting\n    This can handle load balancer and traffic\n\n## Some docker command\nrun docker - docker-compose up\nrun with rebuild image - docker-compose up --build\nrun with rebuild image and on background - docker-compose up -d --build\nrun multiple instance of app - docker-compose up -d --build --scale app=3 #3 is for three instance\ncheck running instances - docker-compose ps or docker ps\nstop docker running instances - docker-compose down\nauto start docker - sudo chkconfig docker on\n\ndocker network inspect bridge\n\n\n\n# install docker in linux server\n## 1. AMAZON LINUX\nsudo su\nyum update -y\namazon-linux-extras install docker\nsystemctl start docker\nsystemctl enable docker\nusermod -a -G docker ec2-user\n# check docker status\ndocker info \n# download project\ngit clone -b master \u003cyour-git-URL\u003e\n# download docker composer\nsudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose \nsudo chmod +x /usr/local/bin/docker-compose\n# write this line on ~/.bashrc file for permanent setup\nexport PATH=$PATH:/usr/local/bin/\ndocker-compose version\n# run project\ndocker-compose up -d --build --scale app=5\n\n## Setup ECR for docker image upload\n1. Create a new repo in ECR\n2. Setup IAM role in EC2 instance\n    a. go to IAM role\n    b. create role\n    c. select EC2\n    d. next go to permission\n    e. select AmazonEC2ContainerRegistryFullAccess \n    f. next go to tag (Optional)\n    g. next go to create role , name the role like docker-ec2-ecr-access-role and Create Role.\n3. Attach role in EC2 inatance\n    a. select instance in ec2 \n    b. go to action\n    c. modify IAM role\n4. Setup aws cli and configure aws  using command \"aws configure\"\n5. run from push command instruction in ECR dashboard\nRetrieve an authentication token and authenticate your Docker client to your registry.\nUse the AWS CLI:\n\n=\u003e aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin \u003caws-id-here\u003e.dkr.ecr.ap-south-1.amazonaws.com\nNote: If you receive an error using the AWS CLI, make sure that you have the latest version of the AWS CLI and Docker installed.\nBuild your Docker image using the following command. For information on building a Docker file from scratch see the instructions here . You can skip this step if your image is already built:\n\n=\u003e docker build -t test-docker app/\nAfter the build completes, tag your image so you can push the image to this repository:\n\n=\u003e docker tag test-docker:latest \u003caws-id-here\u003e.dkr.ecr.ap-south-1.amazonaws.com/test-docker:latest\nRun the following command to push this image to your newly created AWS repository:\n\n=\u003e docker push \u003caws-id-here\u003e.dkr.ecr.ap-south-1.amazonaws.com/test-docker:latest\n\n6. Pull ECR file in EC2 or where you want\ndocker pull \u003caws-id-here\u003e.dkr.ecr.ap-south-1.amazonaws.com/test-docker \n\n\n\n# database example, how to save data to database\nChange your code as per your requirements and more security to save and pass data\nwhile creating send sha256 of password\n// Example sha256(\"12345\") will be \"5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5\"\n{\n    \"fullname\": \"Admin\",\n    \"username\": \"admin\",\n    \"password\": sha256(plaintext_password), \n    \"email\": \"admin@gmail.com\",\n    \"mobile\": \"12345678\"\n}\n\nsame while login \n{\n    \"username\": \"username/email\",\n    \"password\": \"5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5\"\n}","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntshvicky%2Fflask-mysql-mvc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fntshvicky%2Fflask-mysql-mvc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntshvicky%2Fflask-mysql-mvc/lists"}