-
Notifications
You must be signed in to change notification settings - Fork 4
Design: Python backend choice
Vimanyu Aggarwal edited this page May 21, 2025
·
2 revisions
Here is the analysis of server frameworks between flask and django:
- Fetch data from Airbnb, such as listing ID, registration number, property type
- Evaluate a listing based on certain policies
- Triggered manually or on weekly basis
- Data Fetching from Airbnb:
- Endpoint: /fetch_airbnb_data
- Method: GET (to fetch data)
- Description: This endpoint triggers the workflow to fetch data from Airbnb, such as listing ID, registration number, property type.
- Controller Function: This function will handle the request to fetch data from Airbnb using appropriate authentication and API calls.
- Listing Evaluation Policies:
- Endpoint: /evaluate_listing
- Method: POST (to evaluate a listing)
- Description: This endpoint triggers the workflow to evaluate a listing based on specified policies, such as checking for an invalid registration number.
- Controller Function: This function will receive listing data as input, apply evaluation policies, and return the evaluation result.
- Scheduler (for Weekly Trigger):
- Method: Use a cron job or a scheduling library like Celery to trigger the workflows on a weekly basis.
- Description: Set up a scheduler to automatically trigger the workflows at specified intervals.
Pros:
- Lightweight and minimalistic, providing flexibility to structure the application as needed.
- Easy to get started with and offers great simplicity, making it suitable for smaller projects.
- Wide range of extensions available for various functionalities, enabling easy integration of different features.
- Well-suited for building RESTful APIs due to its simplicity and minimal overhead.
Cons:
- Requires more manual setup and configuration compared to Django.
- Lack of built-in features like ORM and admin panel, which might require additional libraries or custom implementations. Need external dependency, like Flask-SQLAlchelmy extension, for easy access to ORM.
- Need to handle more low-level details compared to higher-level frameworks like Django.
- Scaling might require additional effort as the application grows in complexity.
Trade-offs:
- Flask offers more control and flexibility but requires developers to make more decisions about the application structure and components.
Pros:
- Batteries-included framework with a rich set of built-in features, including ORM, admin panel, authentication, and session management, which speeds up development.
- Follows the "Convention over Configuration" principle, providing a standardized structure and reducing the need for manual setup and configuration.
- Excellent built-in security features, such as protection against common web vulnerabilities like CSRF and XSS.
- Strong community support with extensive documentation and a large ecosystem of third-party packages.
Cons:
- Can be considered more opinionated compared to Flask, which might not suit all use cases or preferences.
- Learning curve might be steeper for beginners due to its comprehensive nature and reliance on Django-specific concepts.
- Might introduce some overhead due to its monolithic nature, especially for simpler applications where not all features are needed.
Trade-offs:
- Django provides a more structured and feature-rich environment out-of-the-box, which can accelerate development but might limit flexibility compared to Flask.