In this book, you will go from learning the basic principles to the practical implementation of full-fledged server applications in Python: from low-level sockets and protocols to architecture and production deployment. The book is unique in that it offers not just one 'correct' path but compares three mature stacks - Flask, Django, and FastAPI - on real projects, showing where simplicity is appropriate, where out-of-the-box completeness is needed, and where speed and asynchronicity are critical.
The structure of the book is coherent: from the fundamentals of server programming (client-server architecture, protocols for data transmission HTTP, HTTPS, and WebSocket, low-level work with sockets in Python) to creating several real projects, including a CRM system on Django, a telegram bot with full server logic, a REST API for a mobile application, and an interactive chat with WebSocket.
We will study the main aspects of working with databases in server applications: choosing the type of storage according to the load profile and data structure; methods for working with three popular ORMs; a clear process for making changes to the schema without downtime; ready-made templates for connecting to PostgreSQL/MySQL/SQLite/MongoDB, and much more.
We will analyze the key principles of scaling and optimizing server applications: you will learn to use load balancers with Nginx and Gunicorn, apply effective caching strategies with Redis and Memcached, implement background tasks with Celery and RabbitMQ, as well as deploy containers using Docker and Kubernetes. Special attention is paid to security issues and various methods of protecting data and applications: using TLS/SSL for encrypting connections, implementing JWT tokens and OAuth 2.0 for user authentication, protecting against the most common attacks (SQL injections, cross-site scripting (XSS), and cross-site request forgery (CSRF)).
We will also consider modern approaches to application deployment by studying the configuration of server infrastructure on AWS, Heroku, DigitalOcean, as well as the configuration of the Nginx web server and the Gunicorn process manager for production.