This Python Flask microservice provides an API endpoint for converting weights from pounds to kilograms. It's a simple and lightweight service designed for ease of use and integration into larger systems or for educational purposes.
- Conversion Endpoint: A POST endpoint accepting weight in pounds and returning the equivalent weight in kilograms.
- CORS Enabled: Cross-Origin Resource Sharing (CORS) is enabled, allowing the service to be accessed from different domains.
- Python 3.x
- Flask
- Flask-CORS
First, clone the repository or download the source code. Then, install the required dependencies:
pip install Flask flask-cors
To run the service, execute the following command:
python app.py
The service will start on localhost
at port 5000
.
Send a POST request to the /convert
endpoint with a JSON payload containing the weight in pounds. For example:
curl -X POST -H "Content-Type: application/json"
-d '{"pounds": 150}'
http://localhost:5000/convert
The service will return a JSON response containing the weight in kilograms:
{
"kilograms": 68.0388555
}