This repository contains my solution for the Django evaluation, which consists of three problem sets. Each problem set is described below along with additional submission details.
Write a regular expression to extract all the numbers with an orange color background from the given JSON-like text.
The regex to extract numbers with an orange color background is as follows:
import re
data = '{"orders":[{"id":1},{"id":2},{"id":3},{"id":4},{"id":5},{"id":6},{"id":7},{"id":8},{"id":9},{"id":10},{"id":11},{"id":648},{"id":649},{"id":650},{"id":651},{"id":652},{"id":653}],"errors":[{"code":3,"message":"[PHP Warning #2] count(): Parameter must be an array or an object that implements Countable (153)"}]}'
matches = re.findall(r'"id":(\d+)|"code":(\d+)', data)
result = [match[0] or match[1] for match in matches if any(match)]
print(result)
Create a web application with API endpoints for admin-facing and user-facing functionalities.
The web app consists of two components: admin-facing and user-facing.
- Admin users can add Android apps and assign points to them.
- Users can view the apps added by the admin and check their earned points.
- Users can sign up, log in, and upload screenshots to verify completed tasks.
- Endpoint: POST /next/signup
- Description: Sign up a new user.
- Endpoint: POST /next/login
- Description: Login with existing user credentials.
- Endpoint: POST /next/createapp
- Description: Create a new application.
- Endpoint: GET /next/getapps
- Description: Get a list of all applications.
- Endpoint: POST /next/assignapp
- Description: Assign an application to a user.
- Endpoint: GET /next/tasks
- Description: Get a list of tasks.
- Endpoint: GET /next/points
- Description: Get user's points information.
- next-front/ # Frontend for the problem statement
- next-back/ # Backend for the problem statement
- next-back/requirements.txt # Required packages and dependencies
-
The application Frontend has been deployed to deployment_link.
-
The application Backend has been deployed to deployment_link.
- Admin User Credentials for deployed app are
- Username or email : Admin
- Password : Admin
- App Working Video Link
To run the project locally, please follow these steps:
- Clone the repository:
git clone https://github.com/kiranrokkam09/next-labs.git
- Move to the next-back directory where the backend is located:
cd next-back
- Create Virtual Environment:
python -m virtualenv venv
- Activate the Virtual Environment:
venv/scripts/activate
- Install the required dependencies:
pip install -r requirements.txt
- Create the database migrations:
python manage.py makemigrations
- Run the database migrations:
python manage.py migrate
- Create admin user fo the app:
python manage.py createsuperuser
- Start the development server:
python manage.py runserver
Answer the following questions:
A. Write a note about your choice of system to schedule periodic tasks and its scalability.
For scheduling periodic tasks in a Python and Django environment, I have chosen Celery as the preferred system. Celery is a distributed task queue framework that allows for efficient and reliable task scheduling and execution.
Reasons for Choosing Celery:
- Reliability: Celery is known for its reliability and fault-tolerance. It has built-in mechanisms to handle task failures and retries, ensuring that scheduled tasks are executed consistently and reliably.
- Scalability: Celery is designed to handle large-scale distributed task processing. It supports distributed task queues and can easily scale horizontally by adding more worker nodes as the workload increases.
- Task Prioritization: Celery provides the flexibility to prioritize tasks based on their importance or urgency. This feature ensures that critical tasks are executed promptly, while less time-sensitive tasks are processed accordingly.
- Integration with Django: Celery integrates seamlessly with Django, making it an ideal choice for scheduling periodic tasks in Django applications. It leverages Django's database and ORM to store task results and track task progress. Possible Challenges and Solutions
By adopting Celery for scheduling periodic tasks in Python and Django, you can benefit from its reliability, scalability, and seamless integration with Django, providing a robust foundation for efficient task execution in production environments.
B. Explain the circumstances in which you would use Flask instead of Django, and vice versa.
Flask and Django are both popular web frameworks in Python, but they have different strengths and are suitable for different circumstances. Here are some scenarios where you would choose one over the other:
Use Flask:
- Lightweight and Flexibility: If you have a small-scale project or need a lightweight framework with minimal dependencies, Flask is a good choice. It allows for more flexibility in terms of choosing components and libraries, making it easier to customize and tailor to specific project requirements.
- Microservices and APIs: Flask is well-suited for building microservices and APIs. Its minimalistic nature and modular design make it efficient for creating lightweight and fast API endpoints.
- Learning and Simplicity: If you are new to web development or prefer a simpler framework, Flask's minimalistic approach and straightforward design make it easier to grasp and learn.
Use Django:
- Rapid Development: Django is known for its "batteries included" philosophy, providing a comprehensive set of tools and features out of the box. It excels in rapid development scenarios, where you need to quickly build and deploy complex web applications with built-in functionality for authentication, database management, admin interface, and more.
- Large-Scale Projects: When working on large-scale projects that require extensive functionality, Django's opinionated structure and conventions help maintain organization and consistency. It provides a robust ORM, authentication system, form handling, and powerful templating engine, reducing the need for manual configuration.
- Content Management Systems (CMS): If your project involves building a CMS or requires content management capabilities, Django's admin interface provides an intuitive and powerful administration tool to manage content models and user permissions.
The decision should be based on the specific requirements of the project, the development team's familiarity with the frameworks, and the desired trade-offs between simplicity, flexibility, and built-in functionality.