DI05000091 · Semester 5 · 5G scheme
Web Development using Python
Notes and solutions following the Gujarat Technological University (GTU) syllabus for DI05000091. Independent material — not issued by the university.
Materials
Complete Book
The whole syllabus, unit by unit, written for the exam.
Complete Book
124 pages
Premium Preview · 11 pages
Syllabus units
Unit 1: Python Object-Oriented Programming (OOP)
- Introduction to OOP
- Classes, Objects, Attributes and Methods
- Constructors (__init__), destructors (__del__) and self parameter
- Encapsulation and Data hiding: Public, protected (_), and private (__) attributes/methods, Accessing data using methods
- Inheritance: Single inheritance, Multilevel inheritance, Use of super()
- Polymorphism: Method overriding, Operator overloading
- Abstraction: Abstract classes, Use of abc module
- Magic methods (Dunder Methods): __str__, __repr__, __len__, __add__, __eq__ etc.
Unit 2: Python Database Programming
- Introduction to SQLite and PostgreSQL
- Python Database Connectivity using SQLite (sqlite3 module): Connecting to database, Executing SQL queries
- SQL Commands using sqlite3: DDL (CREATE TABLE, ALTER TABLE, DROP TABLE), DML (INSERT, SELECT with WHERE and ORDER BY, UPDATE, DELETE), Aggregate functions (COUNT, SUM, AVG, MIN, MAX), GROUP BY and HAVING clause
- Parameterized Queries to prevent SQL injection (using ? placeholders)
- Introduction to ORM (Object Relational Mapping): Need for ORM in modern web applications, ORM concept, Brief introduction to ORM tools used in Python web frameworks (SQLAlchemy, Django ORM)
Unit 3: Flask Framework
- Introduction to Flask: Introduction to web frameworks, Micro (Flask) vs. Full-stack (Django) Frameworks, Flask framework features and advantages, Flask application Structure
- Routing, Views and URL Handling: Routing concept in Flask, Defining routes with @app.route() decorator, URL Variable rules, converters, HTTP methods: specifying methods=['GET', 'POST'], Using url_for() for dynamic link generation
- Dynamic UI with Jinja2 Templating Engine: Jinja2 template syntax, Rendering templates using render template(), Variables: {{variable}}, Filters {{name|title}}, Control structures: {% if %}, {% for %}, Template inheritance: {% extends 'base.html' %}, {% block content %}, Linking CSS, JavaScript using the static folder/CDN
- Forms Handling with WTForms: Form classes: class LoginForm(FlaskForm): with fields/validators, Template integration: {{form. hidden tag ()}}, {{form. field. Label}}, Processing: form.validate_on_submit(), accessing form.data
- Flask with Database: Connecting Flask with SQLite database, Creating database and performing CRUD operations, Displaying database data on web pages
- Sessions, Cookies, and Flash Messages: Sessions: session['key'] = value, session.pop('key'), Cookies: response.set_cookie ('key', 'value'), Flash messages: flash(), display with get_flashed_messages()
Unit 4: Django Framework
- files
- Django ORM basics
Unit 5: Advance Django: REST APIs, Security and Deployment
- Authentication and Security: Django's built-in auth system (User model, groups, permissions), Registration, login, and logout views, protecting views with decorators/mixins (@login_required, LoginRequiredMixin), and permission checks with PermissionRequiredMixin, Web Security Best Practices for protection against common vulnerabilities: Cross-Site Request Forgery (CSRF): middleware + tokens, Cross-Site Scripting (XSS): auto-escaping, SQL injection (ORM usage), HTTPS enforcement
- Django Middleware & Sessions
- Django REST Framework (DRF): Introduction to DRF, Serializers: ModelSerializer for Post/Category, validation (validate(), create()), Function-based views using @api_view, Class-based views using APIView and Generic Views, Routers: DefaultRouter(), URL auto-generation (/api/posts/)
- Deployment: Environment variables: using python-dotenv or django-environ
About this course
Web applications form the backbone of modern software systems used in education, business, healthcare, and government sectors. Python is widely adopted for web development due to its simplicity, readability, and strong open-source ecosystem. Although students have prior knowledge of basic Python and front-end technologies, industry-oriented web development requires skills in object-oriented programming and database-driven application design. This subject introduces Python Object-Oriented Programming and database concepts essential for building robust server-side applications. Students learn to develop dynamic web applications using popular open-source frameworks such as Flask and Django. The course also exposes learners to REST APIs, enabling integration between different software systems. Emphasis is given to web application security, authentication, and secure data handling. Students gain hands-on experience in developing and deploying web applications using open-source tools. Overall, this subject enhances practical skills and prepares students for entry-level roles in Python-based web and full-stack development.