PYTHON FULL STACK
DEVELOPMENT WITH
MACHINE LEARNING
COURSE
OBJECTIVES
Understand RESTful architecture and core backend concepts
Build CRUD APIs using Python and Flask
Handle JSON data, routing, and custom error responses in Flask
Implement JWT-based authentication and role-based access
control
Process and serialize data efficiently using JSON/XML formats
Integrate caching in Flask using Redis for performance
optimization
UNIT - I
PYTHON FOR
BACKEND
DEVELOPMENT
1. BACKEND
FUNDAMENTALS
Handles server-side logic and database interactions
Powers data processing, authentication, and API services
Frontend handles user interface; backend handles logic and
storage
Common technologies: Python (Flask/Django), Node.js, Java, PHP,
etc.
WHAT IS BACKEND
DEVELOPMENT?
REST = REpresentational State Transfer
A standard for web services and APIs
Core REST constraints:
⟶ Stateless: No session info stored on server
⟶ Client-Server separation
⟶ Cacheable responses
⟶ Uniform Interface (standard methods)
Benefits: Scalability, simplicity, reusability
RESTFUL ARCHITECTURE
1. BACKEND
FUNDAMENTALS
GET – Fetch data (Read)
POST – Create new data (Insert)
PUT – Update existing data
DELETE – Remove data
Each method maps to a CRUD operation
HTTP METHODS
1. BACKEND
FUNDAMENTALS
1. BACKEND
FUNDAMENTALS
HTTP METHODS
RESTful APIs are centered around resources, not actions.
Resources represent data objects (e.g., users, products).
Good Practices:
• Use nouns:
/users, /products/123, /orders/456/items
• Represent hierarchy using slashes:
/users/123/orders Orders of a specific user
→
• Keep endpoints intuitive, consistent, and predictable
Avoid:
• Using verbs:
/getUser, /createOrder, /updateProduct
• RESTful APIs already use HTTP methods to define actions:
GET /users retrieve users
→
POST /orders create a new order
→
RESOURCE-BASED ENDPOINT DESIGN
1. BACKEND
FUNDAMENTALS
Versioning: /api/v1/
Use proper HTTP status codes (200, 404, 500, etc.)
Standard format: JSON
Send clear error messages
Add pagination, filtering, and sorting for large datasets
REST API DESIGN BEST PRACTICES
1. BACKEND
FUNDAMENTALS
2. FLASK ESSENTIALS
INTRODUCTION TO
FLASK
A lightweight Python web framework
Ideal for REST API development
Simple to use, minimal setup, highly
extensible
2. FLASK ESSENTIALS
SETTING UP A FLASK PROJECT
Install Flask: pip install flask
Create a file: app.py
Basic app structure:
Run: python app.py
from flask import Flask
app = Flask(__name__)
app.route("/")
def home():
return "Hello, Flask!"
2. FLASK ESSENTIALS
SETTING UP A FLASK PROJECT
2. FLASK ESSENTIALS
ROUTING AND REQUEST HANDLING
Use @app.route("/path") for defining
endpoints
Handle request types: GET, POST, PUT, DELETE
Access query/path parameters:
request.args.get('name') # query param
2. FLASK ESSENTIALS
ROUTING AND REQUEST HANDLING
2. FLASK ESSENTIALS
WORKING WITH JSON
Read request body: data = request.get_json()
Return JSON response: return jsonify(data)
Use JSON for data exchange between
frontend & backend
2. FLASK ESSENTIALS
CUSTOM ERROR HANDLING
The process of catching and responding to
application errors gracefully.
Prevents application crashes and improves
user experience.
Why Custom Error Handling?
• Custom messages give clearer
information to clients.
• Helps in logging, debugging, and
consistent API responses.
2. FLASK ESSENTIALS
CUSTOM ERROR HANDLING
3. BUILDING CRUD APIS
WITH FLASK
WHAT IS CRUD?
Basic operations:
• Create (POST)
• Read (GET)
• Update (PUT)
• Delete (DELETE)
Foundation of REST API functionality
3. BUILDING CRUD APIS
WITH FLASK
IMPLEMENTING CRUD IN FLASK
Why CRUD in Flask?
• Enables full interaction with application data.
• Essential for building RESTful APIs.
• Flask makes CRUD operations simple with route decorators.
Flask Route Definitions for CRUD:
@app.route("/items", methods=["POST"]) # Create
@app.route("/items", methods=["GET"]) # Read all
@app.route("/items/<int:id>", methods=["GET"]) # Read one
@app.route("/items/<int:id>", methods=["PUT"]) # Update
@app.route("/items/<int:id>", methods=["DELETE"]) # Delete
3. BUILDING CRUD APIS
WITH FLASK
IMPLEMENTING CRUD IN FLASK
Flask Route Definitions for CRUD:
@app.route("/items", methods=["POST"]) # Create
@app.route("/items", methods=["GET"]) # Read all
@app.route("/items/<int:id>", methods=["GET"]) # Read one
@app.route("/items/<int:id>", methods=["PUT"]) # Update
@app.route("/items/<int:id>", methods=["DELETE"]) # Delete
3. BUILDING CRUD APIS
WITH FLASK
IMPLEMENTING CRUD IN FLASK
3. BUILDING CRUD APIS
WITH FLASK
IMPLEMENTING CRUD IN FLASK
3. BUILDING CRUD APIS
WITH FLASK
IN-MEMORY DATA STORAGE
Use Python list/dict for testing:
items = [ ]
items.append({"id": 1, "name": "Book"})
Pros:
• Easy to set up
• No DB dependency
Cons:
• Temporary storage
• Not persistent across server restarts
4. DATABASE
INTEGRATION
INTRODUCTION TO SQLITE
Lightweight, file-based relational database
No server setup required
Ideal for testing and small-scale projects
4. DATABASE
INTEGRATION
import sqlite3
conn = sqlite3.connect('data.db')
cursor = conn.cursor()
CONNECTING FLASK TO SQLITE
Use Python's built-in sqlite3 module
SQL Operations:
• Create tables
• Insert data
• Query records
• Update and delete entries
Close connection after operations
4. DATABASE
INTEGRATION
CONNECTING FLASK TO SQLITE
THANK YOU
Our Telephone
Our Email
Our Website
+91 7395914690
connect@enlightwisdom.co
m
https://enlightwisdom.com

python full stack development with machi

  • 1.
    PYTHON FULL STACK DEVELOPMENTWITH MACHINE LEARNING
  • 2.
    COURSE OBJECTIVES Understand RESTful architectureand core backend concepts Build CRUD APIs using Python and Flask Handle JSON data, routing, and custom error responses in Flask Implement JWT-based authentication and role-based access control Process and serialize data efficiently using JSON/XML formats Integrate caching in Flask using Redis for performance optimization
  • 3.
    UNIT - I PYTHONFOR BACKEND DEVELOPMENT
  • 4.
    1. BACKEND FUNDAMENTALS Handles server-sidelogic and database interactions Powers data processing, authentication, and API services Frontend handles user interface; backend handles logic and storage Common technologies: Python (Flask/Django), Node.js, Java, PHP, etc. WHAT IS BACKEND DEVELOPMENT?
  • 5.
    REST = REpresentationalState Transfer A standard for web services and APIs Core REST constraints: ⟶ Stateless: No session info stored on server ⟶ Client-Server separation ⟶ Cacheable responses ⟶ Uniform Interface (standard methods) Benefits: Scalability, simplicity, reusability RESTFUL ARCHITECTURE 1. BACKEND FUNDAMENTALS
  • 6.
    GET – Fetchdata (Read) POST – Create new data (Insert) PUT – Update existing data DELETE – Remove data Each method maps to a CRUD operation HTTP METHODS 1. BACKEND FUNDAMENTALS
  • 7.
  • 8.
    RESTful APIs arecentered around resources, not actions. Resources represent data objects (e.g., users, products). Good Practices: • Use nouns: /users, /products/123, /orders/456/items • Represent hierarchy using slashes: /users/123/orders Orders of a specific user → • Keep endpoints intuitive, consistent, and predictable Avoid: • Using verbs: /getUser, /createOrder, /updateProduct • RESTful APIs already use HTTP methods to define actions: GET /users retrieve users → POST /orders create a new order → RESOURCE-BASED ENDPOINT DESIGN 1. BACKEND FUNDAMENTALS
  • 9.
    Versioning: /api/v1/ Use properHTTP status codes (200, 404, 500, etc.) Standard format: JSON Send clear error messages Add pagination, filtering, and sorting for large datasets REST API DESIGN BEST PRACTICES 1. BACKEND FUNDAMENTALS
  • 10.
    2. FLASK ESSENTIALS INTRODUCTIONTO FLASK A lightweight Python web framework Ideal for REST API development Simple to use, minimal setup, highly extensible
  • 11.
    2. FLASK ESSENTIALS SETTINGUP A FLASK PROJECT Install Flask: pip install flask Create a file: app.py Basic app structure: Run: python app.py from flask import Flask app = Flask(__name__) app.route("/") def home(): return "Hello, Flask!"
  • 12.
    2. FLASK ESSENTIALS SETTINGUP A FLASK PROJECT
  • 13.
    2. FLASK ESSENTIALS ROUTINGAND REQUEST HANDLING Use @app.route("/path") for defining endpoints Handle request types: GET, POST, PUT, DELETE Access query/path parameters: request.args.get('name') # query param
  • 14.
    2. FLASK ESSENTIALS ROUTINGAND REQUEST HANDLING
  • 15.
    2. FLASK ESSENTIALS WORKINGWITH JSON Read request body: data = request.get_json() Return JSON response: return jsonify(data) Use JSON for data exchange between frontend & backend
  • 16.
    2. FLASK ESSENTIALS CUSTOMERROR HANDLING The process of catching and responding to application errors gracefully. Prevents application crashes and improves user experience. Why Custom Error Handling? • Custom messages give clearer information to clients. • Helps in logging, debugging, and consistent API responses.
  • 17.
  • 18.
    3. BUILDING CRUDAPIS WITH FLASK WHAT IS CRUD? Basic operations: • Create (POST) • Read (GET) • Update (PUT) • Delete (DELETE) Foundation of REST API functionality
  • 19.
    3. BUILDING CRUDAPIS WITH FLASK IMPLEMENTING CRUD IN FLASK Why CRUD in Flask? • Enables full interaction with application data. • Essential for building RESTful APIs. • Flask makes CRUD operations simple with route decorators. Flask Route Definitions for CRUD: @app.route("/items", methods=["POST"]) # Create @app.route("/items", methods=["GET"]) # Read all @app.route("/items/<int:id>", methods=["GET"]) # Read one @app.route("/items/<int:id>", methods=["PUT"]) # Update @app.route("/items/<int:id>", methods=["DELETE"]) # Delete
  • 20.
    3. BUILDING CRUDAPIS WITH FLASK IMPLEMENTING CRUD IN FLASK Flask Route Definitions for CRUD: @app.route("/items", methods=["POST"]) # Create @app.route("/items", methods=["GET"]) # Read all @app.route("/items/<int:id>", methods=["GET"]) # Read one @app.route("/items/<int:id>", methods=["PUT"]) # Update @app.route("/items/<int:id>", methods=["DELETE"]) # Delete
  • 21.
    3. BUILDING CRUDAPIS WITH FLASK IMPLEMENTING CRUD IN FLASK
  • 22.
    3. BUILDING CRUDAPIS WITH FLASK IMPLEMENTING CRUD IN FLASK
  • 23.
    3. BUILDING CRUDAPIS WITH FLASK IN-MEMORY DATA STORAGE Use Python list/dict for testing: items = [ ] items.append({"id": 1, "name": "Book"}) Pros: • Easy to set up • No DB dependency Cons: • Temporary storage • Not persistent across server restarts
  • 24.
    4. DATABASE INTEGRATION INTRODUCTION TOSQLITE Lightweight, file-based relational database No server setup required Ideal for testing and small-scale projects
  • 25.
    4. DATABASE INTEGRATION import sqlite3 conn= sqlite3.connect('data.db') cursor = conn.cursor() CONNECTING FLASK TO SQLITE Use Python's built-in sqlite3 module SQL Operations: • Create tables • Insert data • Query records • Update and delete entries Close connection after operations
  • 26.
  • 27.
    THANK YOU Our Telephone OurEmail Our Website +91 7395914690 connect@enlightwisdom.co m https://enlightwisdom.com