Advance Python Programming (CY-406) - Important Questions
-
Unit 414 Marks High Priority
Write a Python program to implement a custom HTTP server that handles HTTP GET and POST requests, serves static files from a specified document root with correct MIME types, and returns appropriate HTTP response codes for common error conditions (404, 405, 500). Provide the complete source code, explain key components (request parsing, header handling, response formation), and show sample inputs and server responses.
Core practical implementation of Unit 4: building a custom HTTP server that handles basic HTTP methods and static file serving; aligns with frequently asked practical problems in past papers.
-
Unit 410 Marks High Priority
Explain and demonstrate how to implement concurrent handling of multiple clients in a custom HTTP server using threading. Provide a working Python example (e.g., using socketserver.ThreadingMixIn or ThreadingHTTPServer) that handles multiple simultaneous requests. Discuss implications of the Global Interpreter Lock (GIL) on this threaded HTTP server and when threading is appropriate versus other concurrency models.
Concurrency in custom HTTP servers is a core follow-up topic; ties into global questions about concurrent TCP servers and GIL implications.
-
Unit 47 Marks Medium Priority
Demonstrate how to add TLS/SSL support to a custom Python HTTP server. Provide code that configures an SSLContext or uses ssl.wrap_socket to serve HTTPS, explain certificate generation and loading, and discuss practical considerations such as certificate validation and secure protocol/cipher selection.
Secure transport (HTTPS) for custom servers is a common advanced requirement in web server coursework.
-
Unit 410 Marks Medium Priority
Explain and implement support for chunked transfer encoding and large file uploads in a custom HTTP server. Provide code showing how to receive a large POST upload in streaming fashion, how to send responses using chunked transfer encoding, and discuss memory and performance considerations.
Handling large payloads and chunked transfer is an important practical server capability and performance consideration.
-
Unit 47 Marks Medium Priority
Describe and implement basic authentication and simple session management (using cookies) in a custom Python HTTP server. Provide code snippets that validate credentials (Basic Auth), set and read session cookies, and discuss security pitfalls and recommended mitigations.
Authentication and state management are typical functional requirements for HTTP servers and web applications.
-
Unit 410 Marks Medium Priority
Explain the difference between WSGI and ASGI. Show how a custom Python HTTP server can be adapted to run WSGI applications (using wsgiref.simple_server or a custom adapter) and outline steps required to support ASGI applications (conceptual overview). Provide an example of serving a simple WSGI application.
Interfacing custom servers with application protocols (WSGI/ASGI) connects server implementation with Python web application ecosystems.
-
Unit 414 Marks Medium Priority
Implement a custom RESTful API server in Python using either http.server or socketserver that supports routing, JSON request parsing, and proper HTTP status codes (200, 201, 400, 404, 500). Include endpoints for basic CRUD operations on an in-memory resource, show example requests and responses, and include unit tests or curl examples demonstrating the API.
RESTful API implementation is a standard exam-style practical exercise combining HTTP handling and JSON parsing.
-
Unit 47 Marks Medium Priority
Discuss and implement logging, structured error handling, and security best practices in a custom HTTP server. Provide code examples showing request/response logging, exception-to-HTTP-error translation, input validation, header parsing robustness, and basic rate-limiting or IP-based throttling strategies.
Operational concerns such as logging, error handling and basic security are essential for robust servers; typically asked as conceptual plus code.
-
Unit 414 Marks Medium Priority
Compare threading, multiprocessing, and asyncio approaches for handling concurrency in a custom HTTP server. Implement three minimal server variants (threaded, process-based, and asyncio-based), run a simple benchmark illustrating throughput and CPU utilization under load, and analyze the trade-offs (latency, throughput, complexity, memory usage).
Comparative concurrency evaluation is often required to justify design choices and demonstrate measurable differences.
Quick Add to Notes
Save questions, your own notes and screenshots into notes filed by unit. It takes a free account.
Create free accountHave an account? Log in
Notes Panel