Member-only story
Number Classification API
4 min read 3 days ago
This is a DevOps/Backend guide to building a simple API that classifies numbers and returns fun mathematical facts about those numbers. The API checks the following —
- Checks if a number is prime, perfect, or an Armstrong number.
- Returns whether a number is odd or even.
- Fetches a fun fact from NumbersAPI.
For this test we will need the following to help us complete the task.
- A GitHub account
- Render Account
- Basic understanding of Python
Step 1 : Implementing a testing the code locally
- Create a project folder for our api
mkdir flask-number-api
cd flask-number-api
2. Create the application files
— app.py – This will contain your Flask code.
— requirements.txt – List your dependencies.
In the app.py add the following block of code
#Importing Necessary Modules
#Flask: A web framework we will use to create the API.
#request: Retrieves the input number from the API request.
#jsonify: Converts Python dictionaries into JSON responses.
#CORS: Enables Cross-Origin Resource Sharing (CORS), allowing requests from different…