This repository contains the code for this blogpost on StackAbuse.
Kindly ensure you have the following installed on your machine:
- Python 3
- Pipenv
- AWS CLI Tool
- Git
- An IDE or Editor of your choice
- Clone the repository
$ git clone https://github.com/ro6ley/flask-drive.git
- Check into the cloned repository
$ cd flask-drive
- If you are using Pipenv, setup the virtual environment and start it as follows:
$ pipenv install && pipenv shell
- Install the requirements
$ pip install -r requirements.txt
- Configure AWS CLI
$ aws configure
-
Create a bucket on AWS Dashboard and update it on the
app.py
file on line 10. -
Run the application
$ BUCKET="insert_bucket_name_here" FLASK_APP=app.py FLASK_RUN_PORT=8080 FLASK_ENV=development FLASK_RUN_HOST=0.0.0.0 flask run
- Navigate to http://localhost:8080/storage
Required to have docker, git.
-
build
docker build -t flask-drive .
-
configure
export AWS_ACCESS_KEY_ID="<Your_Access_Key>"
export AWS_SECRET_ACCESS_KEY="<Your_Secret_Key>"
export BUCKET="<Your_Bucket_Name>"
export AWS_DEFAULT_REGION=eu-west-2
- run
docker run -p 8080:5000 -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY -e BUCKET=$BUCKET -e AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION flask-drive
Navigate to http://localhost:5000/storage
Pull this container with the following Docker command:
docker pull quay.io/denistrofimov/flask-drive
- Bind for 0.0.0.0:5000 failed: port is already allocated
select a different port, "docker run -p 8080:5000" Navigate to http://localhost:8080/storage
Please feel free to raise issues using this template and I'll get back to you.
You can also fork the repository, make changes and submit a Pull Request using this template.