REST API written in Python Flask & DB2
- Download & install Python 3.6
- Download & install Pipenv
python -m pip install -U pip pip3 install pipenv# Clone the repository # Change into the directory cd example-flask # Install all required dependencies with pipenv install --deploy --skip-lock # Activate the project virtual environment pipenv shell # Create an local .env file and replace with the relevant values copy .env.sample .envYou can also set the enviroment variables explicity (OPTIONAL)
set Build_ENV=development set PORT=9000- Install python from vscode extensions market place (ctrl+shift+x) ms-python.python
- Open the command palette in visual studio (ctrl+shift+P) type
>Python: Select Interpreter - Choose the python interpreter of virtual env
('example-flask': pipenv) - Once that is done check the .vscode folder settings.json if the
python.pythonPathpoints to your virtual env. - To debug the applictaion open Run (ctrl+shift+D) and click on the play button besided Run with Python: Flask selected in the drop down.
Start the app in virtual env shell
python run.pyBlue-Prints Specifications
- GET: / - app
- GET: /api/v1/model/ - controller
- GET: /api/v1/model/id - controller
- POST: /api/v1/model/id - controller
- PUT: /api/v1/model/id - controller -DELETE: /api/v1/model/id - controller
Example curl http://localhost:{APP_PORT}/api/v1/model/
cd example-flask # Build the docker image docker build -t shra012/example-flask:1.0 . # Run the docker container and put the port as specified in the .env file docker run -d -p 5000:5000 --name example-flask -e PORT=5000 -e Build_ENV=development shra012/example-flask:1.0 # Check the logs docker logs -f example-flask # Cleaup the container docker stop example-flask && docker rm example-flaskShravankumar Nagarajan