REST API based on Flask. Have these functionalities:
- Endpoint to generate a file of 2MB size(exceeds 2MB, approx. 2.1MB), which contains 4 types of random objects (alphabetical strings, real numbers, integers, alphanumerics).
- Endpoint to download the generated file.
- Endpoint to get a report of total number of each random object.
-
Python version supported: 3.8+
-
Clone the project
git clone git@github.com:adnan-alam/random_objects_project.git
-
Install virtualenv if not installed on system
# package to create virtual environment pip install virtualenv -
Go to dir random_objects_project, create a virtual environment .env
virtualenv -p /usr/bin/python3.8 .env
and activate it
source .env/bin/activate -
Install all the dependencies
pip install -r requirements.txt
-
Run the development server
python manage.py
and the project will be served on
http://127.0.0.1:5000/.
POST /api/v1/random-objects/generateRequest parameter: None
Response (JSON):
{
"url": "/api/v1/download/random_objects.txt"
} GET /api/v1/download/<file_name>Request parameter: None
Response: File
GET /api/v1/random-objects/reportRequest parameter: None
Response (JSON):
# example
{
"total_alphabetical_strings": 50659,
"total_alphanumerics": 46807,
"total_integers": 48352,
"total_real_numbers": 48442
}