https://github.com/kazemmdev/docker-sample-flask
https://github.com/kazemmdev/docker-sample-flask
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kazemmdev/docker-sample-flask
- Owner: kazemmdev
- License: mit
- Created: 2024-07-28T04:48:03.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-07-28T06:45:52.000Z (9 months ago)
- Last Synced: 2025-01-08T15:57:03.306Z (4 months ago)
- Language: Python
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dockerized Sample Flask App
This repository contains a Dockerized Flask application with two main functionalities:1. Compute Fibonacci sequence up to a given number.
2. Predict a value using a simple TensorFlow neural network model.### Getting Started
These instructions will help you set up and run the Flask application inside a Docker container.
Prerequisites
Ensure you have the following installed on your system:
* Docker
* curl (optional, for testing the API via the command line)## EXAMPLE_1: Fibonacci Example
1. Build the Docker image:
```sh
cd fibonacci
docker build -t flask-api .
```2. Run the Docker container:
```sh
docker run -p 4000:4000 flask-api
```3. Test the API using curl:
```sh
curl -X POST http://localhost:4000/predict -H "Content-Type: application/json" -d '{"number": 5}'
```Expected Response:
```json
{
"status": "success",
"fibonacci_sequence": [
{"Fibonacci Numbers": 0},
{"Fibonacci Numbers": 1},
{"Fibonacci Numbers": 1},
{"Fibonacci Numbers": 2},
{"Fibonacci Numbers": 3},
{"Fibonacci Numbers": 5},
{"Fibonacci Numbers": 8},
{"Fibonacci Numbers": 13},
{"Fibonacci Numbers": 21},
{"Fibonacci Numbers": 34}
]
}
```## EXAMPLE_2: TensorFlow Prediction Example
1. Build the Docker image:
```sh
cd tensorflow
docker build -t flask-api .
```2. Run the Docker container:
```sh
docker run -p 4000:4000 flask-api
```3. Test the API using curl:
```sh
curl -X POST http://localhost:4000 -H "Content-Type: application/json" -d '{"number": 1}'
```Expected Response:
```json
{
"input": 1,
"prediction": 0.48668569326400757,
"status": "success"
}
```## License
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
## Acknowledgments
Thanks to the Flask, TensorFlow, and Docker communities for their excellent documentation and tutorials.