- Install python in machine.
- Go to VSCode terminal.
- Enter command as
python -m venv .venv
- Open setting, navigate to Select interpreter.
- If it show venv excutable, select that. Ignore step-6 if this is successful.
- If venv does not exist, go to enter interpreter path. Select "flask_store/.venv/Scripts/python.exe"
- Bin the current terminal
- Open a new terminal
- The project will start with venv. e.g. Path in terminal will have "(.venv)" as start
- Check if virtual environment is active. If not refer to above steps to start venv
- Go to flask_store folder.
- Run
pip install -r requirements.txt
in terminal. - Start flask app with
flask run
this command.
- Check Dockerfile
- Run command
docker build -t <image_name> .
- To run image enter
docker run -dp 5000:5000 <image_name>
Run flask in docker containers
- Hot run the docker container.
- Windows:
docker run -dp 5000:5000 -w /app -v "/c/Documents/yourproject:/app" flask-smorest-api
- Linux, MacOS:
docker run -dp 5000:5000 -w /app -v "$(pwd):/app" flask-smorest-api
- Windows:
- Build a docker image
docker build -t flask-smorest-api .
- Run container
docker run -dp 5000:5000 flask-smorest-api
URL Details:
Rest url http://127.0.0.1:5000/
Swagger url http://127.0.0.1:5000/swagger-ui