Before starting, ensure you have the following installed on your machine:
- Python 3.x: Ensure you have the latest version of Python 3 installed.
- pip: Python package installer.
- virtualenv: For creating isolated Python environments.
Unzip the provided folder to a convenient location on your local machine.
Open a terminal or command prompt and navigate to the project directory. Then, create and activate a virtual environment with the following commands:
For Windows:
cd path\to\unzipped\folder
python -m venv venv
venv\Scripts\activateFor macOS and Linux:
cd path/to/unzipped/folder
python3 -m venv venv
source venv/bin/activateOnce the virtual environment is activated, install the required dependencies using pip:
pip install -r requirements.txtRun the following commands to set up the database and apply migrations:
python manage.py makemigrations
python manage.py migrateYou can populate the database with sample data using the custom management command provided:
python manage.py populate_contactsStart the Django development server:
python manage.py runserverOpen your web browser and navigate to http://127.0.0.1:8000 to ensure the server is running.
Endpoint: /api/register/
Method: POST
Request:
{
"name": "Niraj",
"phone_number": "9960641238",
"email": "nirajamr03@gmail.com",
"password": "password"
}Response:
{
"name": "Niraj",
"phone_number": "9960641238",
"email": "nirajamr03@gmail.com",
}Endpoint: /api/login/
Method: POST
Request:
{
"phone_number": "9960641238",
"password": "password"
}Response:
{
"name": "Niraj",
"phone_number": "9960641238",
"email": "nirajamr03@gmail.com",
}Endpoint: /api/spam/
Method: POST
Authentication: Yes
Request:
{
"phone_number": "4895631786"
}Response:
{
"phone_number": "4895631786",
"spam_count": 1
}Endpoint: /api/search/type=<type>&query<query>
Authentication: Yes
Method: GET
Parameters:
| Key | Value | Examples |
|---|---|---|
| type | name or phone_number |
"name" or "phone_number" |
| query | search_term |
"Nir" or "99" |