filmov
tv
Python - Deploying Bottle Web Apps (NGINX, Gunicorn, Python)
Показать описание
This course, **Bottle, Gunicorn, and NGINX for Production**, introduces deploying a Python web application in a production-ready environment using Bottle, Gunicorn, and NGINX. Starting with a simple Bottle application, participants will understand how to move from development to a robust production setup that handles multiple users, implements reverse proxying, and optimizes performance.
The course begins with setting up a basic Python web app using Bottle, a minimalist web framework. This will introduce the structure and functionality of Bottle applications, demonstrating how to define routes and return simple responses. Students will build a simple app with a random integer feature to visually confirm application updates upon refresh. After covering the basics of Bottle, the course transitions to setting up Gunicorn, a Python Web Server Gateway Interface (WSGI) server designed to handle multiple concurrent users and optimize application performance. Using Gunicorn, students will learn to deploy the Bottle app with multiple workers and bind it to a designated port, ensuring scalable performance for incoming requests.
Key steps involve configuring Gunicorn to interact seamlessly with the Bottle app, including assigning a name to the application instance (`myapp = default_app()`). This approach allows Gunicorn to reference the app instance directly, bypassing the need for the `run()` method when deploying in production. With a solid understanding of running the application on Gunicorn, students will advance to setting up a complete tech stack, including DNS configuration, operating system-level settings, and installation of NGINX as a reverse proxy server.
NGINX will serve as the intermediary between the web and application servers, efficiently handling requests and routing them to the Gunicorn server running the Bottle app. Students will gain hands-on experience configuring NGINX by editing site files and setting up proxy headers. This configuration enhances security and stability while managing requests and responses, freeing up Gunicorn to focus solely on app handling.
A practical aspect of the course involves setting up a user account for the app, securing folder permissions, and isolating application processes for increased security. Attendees will create a virtual environment for the app and install necessary dependencies, ensuring an isolated environment free from conflicting packages or system-wide changes. Participants will also configure the app as a service on Linux systems, using `systemd` for process management. This will cover defining environment variables, setting execution parameters, and automating the app's startup on reboot.
Further security can be added by configuring NGINX to communicate with Gunicorn through a UNIX socket instead of a local IP address. The course details the permission and ownership adjustments required to enable this setup, offering an added layer of security for sensitive applications.
Finally, students will test configurations to ensure everything runs smoothly and address common issues like permission errors, NGINX syntax validation, and service restarts. By the end of this course, students will have a complete end-to-end understanding of deploying Python web applications in a professional setting using Bottle, Gunicorn, and NGINX, ready to scale and handle production traffic securely and efficiently.
Комментарии