Member-only story

Number Classification API

Evan Selunani
4 min read3 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 —

  1. Checks if a number is prime, perfect, or an Armstrong number.
  2. Returns whether a number is odd or even.
  3. Fetches a fun fact from NumbersAPI.

For this test we will need the following to help us complete the task.

  1. A GitHub account
  2. Render Account
  3. Basic understanding of Python

Step 1 : Implementing a testing the code locally

  1. 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…

--

--

Evan Selunani
Evan Selunani

Written by Evan Selunani

Transforming the world, one keystroke at a time.| Certified AWS Cloud Practitioner.

No responses yet