{"id":18640046,"url":"https://github.com/ryankwilliams/flask-file-upload","last_synced_at":"2025-07-20T22:34:28.806Z","repository":{"id":87459256,"uuid":"110838538","full_name":"ryankwilliams/flask-file-upload","owner":"ryankwilliams","description":"Flask application showing how to upload a file, add an entry into database and save the file into a mounted volume.","archived":false,"fork":false,"pushed_at":"2017-11-15T16:02:03.000Z","size":16,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T17:11:55.696Z","etag":null,"topics":["docker","docker-compose","flask-application","openshift-origin","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryankwilliams.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,"zenodo":null}},"created_at":"2017-11-15T13:43:37.000Z","updated_at":"2024-09-09T16:31:01.000Z","dependencies_parsed_at":"2023-06-26T22:40:41.848Z","dependency_job_id":null,"html_url":"https://github.com/ryankwilliams/flask-file-upload","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ryankwilliams/flask-file-upload","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryankwilliams%2Fflask-file-upload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryankwilliams%2Fflask-file-upload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryankwilliams%2Fflask-file-upload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryankwilliams%2Fflask-file-upload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryankwilliams","download_url":"https://codeload.github.com/ryankwilliams/flask-file-upload/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryankwilliams%2Fflask-file-upload/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266210917,"owners_count":23893342,"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":["docker","docker-compose","flask-application","openshift-origin","python"],"created_at":"2024-11-07T05:53:02.978Z","updated_at":"2025-07-20T22:34:28.801Z","avatar_url":"https://github.com/ryankwilliams.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask file upload\n\nThe goal for this project was to understand how to have multiple\nDocker containers or OpenShift pods working together.\n\n## About\n\nThis project will create the following environment:\n\n* Container 1: A flask application which accepts file uplaods, adds an\nentry within a MySQL database and save the file within a mounted volume\npoint.\n\n* Container 2: A MySQL database to store entries.\n\n* Container 3: A mounted volume storage on a host system or a OpenShift\npod which is a persistent volume for storage. Which is connected to the\napplication container.\n\n## Run via Docker\n\nYou should first create a new Python virtual environment to install the\nrequired packages.\n\n```bash\n$ virtualenv ~/venv\n$ source ~/venv/bin/activate\n(venv) $ pip install -r requirements.txt\n```\n\nTo run the project using Docker containers, you first will need to\nbuild the container images. This is done using docker-compose. Run\nthe following command to build the images:\n\n```bash\n(venv) $ make build-images\n```\n\nOnce the images are built successfully, you can now start them. Run\nthe following command to start new containers:\n\n```bash\n(venv) $ make start-containers\n```\n\nYou can now test the application by uploading a file. There is an\nexample file within the root of this project **example.yml** which you\ncan use.\n\n```bash\n$ curl -F 'file=@example.yml' http://0.0.0.0:5000/upload_yml\n```\n\nWhen the flask application container is booted, a mounted volume is\ncreated at the /tmp directory. If you view the latest files in that\ndirectory, you will see new files being created. These files are the\nones that were uploaded.\n\nYou can also login to the container for the database to see the entries\nbeing added.\n\n```bash\n$ docker exec -it \u003ccontainer_name\u003e /bin/bash\n$ mysql -u root -p\nmysql\u003e use kingbob;\nmysql\u003e select * from file_entry;\n```\n\n## Run via OpenShift\n\nYou will need to stand up a local instance of OpenShift and download\nthe oc client binary to communicate with OpenShift. You can use any of\nthe available ways to stand up OpenShift Origin (oc cluster, minishift).\n\nOnce you have your OpenShift instance running, run the following\ncommands to create the pods:\n\n```bash\n# create mysql pod\noc new-app --template=mysql-persistent \\\n--param=DATABASE_SERVICE_NAME=db \\\nMYSQL_ROOT_PASSWORD=password MYSQL_DATABASE=kingbob \\\n-l db=mysql\n\n# create flask-file-upload pod\noc new-app rywillia/flask-file-upload MYSQL_DATABASE=kingbob \\\nMYSQL_ROOT_PASSWORD=password -l app=flask\n\n# expose route for flask application to be accessed externally\noc expose service flask-file-upload --name=flask-file-upload \\\n-l app=flask\n\n# create persistent volume and attach to flask pod deployoment config\noc set volume deploymentconfigs/flask-file-upload \\\n--add --mount-path=/mnt/app --name=app-storage --claim-size=1G\n```\n\nYou can now test the application by uploading a file. There is an\nexample file within the root of this project **example.yml** which you\ncan use.\n\n```bash\n$ curl -F 'file=@example.yml' http://0.0.0.0:5000/upload_yml\n```\n\nWhen the flask application container is booted, a mounted volume is\ncreated at the /tmp directory. If you view the latest files in that\ndirectory, you will see new files being created. These files are the\nones that were uploaded.\n\nYou can also login to the container for the database to see the entries\nbeing added.\n\n```bash\n$ oc exec -it \u003cpod_name\u003e /bin/bash\n$ mysql -u root -h \u003cinternal_ip_of_pod\u003e -P \u003cpod_port\u003e -p\nmysql\u003e use kingbob;\nmysql\u003e select * from file_entry;\n```\n\nYou can run the following commands to clean up your OpenShift pods:\n\n```bash\n# delete all objects associated with database pod\noc delete dc,pod,pvc,services,secret -l db=mysql\n\n# delete all objects associated with flask pod\noc delete imagestream,dc,pod,pvc,services,secret,route -l app=flask\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryankwilliams%2Fflask-file-upload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryankwilliams%2Fflask-file-upload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryankwilliams%2Fflask-file-upload/lists"}