Calculator for Body Mass Index
Currently supported and tested on Linux and Windows environment.
Also supported to run on Docker Container.
Before use this application, please make sure you have been installed these prerequisites:
- python 3.7+. You also can create virtual environment first before running this application
- Docker Container Runtime installed (If you want to run this application as container)
-
Clone this repository to your local
-
Install requirements
On Linux:
python3 -r requirements.txt
On Windows:
python -r requirements.txt
-
For development, run main.py. This command will execute and run application as development web server
On Linux:
python3 main.py
On Windows:
python main.py
-
For production web server, execute this command:
On Linux:
gunicorn -b 0.0.0.0:5000 wsgi:app
On Windows:
waitress-serve --listen=0.0.0.0:5000 wsgi:app
-
From your web browser access the application. Default port is 5000.
Example: localhost:5000
-
Pull image from Docker Hub
docker pull lanandra/bmi-calculator
-
Run container
Example: You can run this container on detached mode and run on default port 5000
docker run -d -p 5000:5000 --name bmi-calculator lanandra/bmi-calculator:latest
-
From your web browser access the application. Default port is 5000.
Example: localhost:5000
-
You can run bmi.py to run application on Command Line Interface
On Linux
python3 bmi.py
On Windows
python bmi.py
If you need REST API service from this application, you can use this method:
-
Before passing directly from browser, you can test using application such as Postman
-
Pass height and weight arguments use POST method. URL for api is
http://localhost:5000/api
-
Example of usage
http://localhost:5000/api?height=167&weight=70
-
Example of output
{ "bmi": 25.1, "label": "Overweight" }
If you are interesting to preview the feature for this app, please check heroku deployment on this link:
Main application: https://lanandra-bmi-calculator.herokuapp.com/
REST API: https://lanandra-bmi-calculator.herokuapp.com/api?height=float&weight=float
Change height and weight for your input, example:
https://lanandra-bmi-calculator.herokuapp.com/api?height=167&weight=70