A simple Python Flask app that checks if a given number is prime, and if not, finds the closest prime number.
You could just run this locally using "flask run", or follow one of the options below to either deploy directly to the Azure cloud, or create it as a container image to deploy anywhere.
The Azure Container Apps service supports directly deploying a web app using the "az containerapp up" CLI command.
This command automatically converts a web app app to a container image and deploys it. Here's an example using the Azure Cloud Shell (which comes with the Azure CLI pre-installed):
- Connect to Azure Cloud shell (https://shell.azure.com)
- Clone this repo:
git clone https://github.com/gbowerman/prime
cd prime
az containerapp up --name prime --source . --ingress external --target-port 5000 --resource-group prime-group
Note: The first time you run "az containerapp up" you'll be prompted to install an Azure CLI extension.
Note: If running on Windows, first install Docker Desktop, and make sure you have git installed.
Change the image tag "prime-app" in the commands below to any name you want to give it.
-
Clone this repo locally (e.g. using git command line or VS Code etc.)
-
cd to the prime directory
-
Build a container image:
docker buildx build . -t prime-app:latest
-
Test locally:
docker run -d --name prime-app-container -p 80:5000 prime-app:latest
-
Connect to the running app at localhost:80
Acknowledgements
Credit to Rahul Upadhyaya (@kavishavi) for the inspiration. (see PrimeContainerapp for the latest version of his project)
License
This project is licensed under the MIT License - see the LICENSE file for details.