No project description provided
Project description
nginx-python
Overview
nginx-python is a Python package designed to automatically and easily configure and host your Python web applications (Django, Flask, FastAPI) with Nginx using simple Python code. This tool aims to streamline the deployment process, reducing the complexity and potential for errors associated with manual configuration.
Features
- Automatic Nginx Configuration: Generate Nginx configuration files tailored to your application’s needs with minimal effort.
- Service Management: Start, stop, and reload Nginx services directly from your Python code.
- SSL Certificate Integration: Optionally integrate Let's Encrypt SSL certificates to secure your applications.
- Multi-Framework Support: Seamlessly supports Django, Flask, and FastAPI web frameworks.
- User-Friendly: Simplifies the deployment process, making it accessible even to developers who are not familiar with server configuration.
Installation
Install Python-nginx via pip:
pip install python-nginx
Usage
Basic Setup
Here’s a quick example of how to set up Nginx for a FastAPI application:
from nginx_python.core import create_nginx_config, manage_service
# Define your server name and application port
server_name = 'example.com'
app_port = 8000
# Generate the Nginx configuration
create_nginx_config(server_name, app_port)
# Start the Nginx service
manage_service('start')
Command-Line Interface
Python-nginx also provides a CLI for easy management:
nginx_python setup --server-name example.com --app-port 8000
nginx_python start
nginx_python stop
nginx_python reload
Configuration File Template
The default Nginx configuration template used by Python-nginx:
server {
listen 80;
server_name {{ server_name }};
location / {
proxy_pass http://127.0.0.1:{{ app_port }};
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
error_page 404 /404.html;
location = /404.html {
internal;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
internal;
}
}
Contributing
Contributions are welcome! Please read our contributing guide to get started.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
GitHub Actions Workflow
This repository includes a GitHub Actions workflow to automatically test and publish the package to PyPI. For more information, see the workflow file.
Contact
For any questions or feedback, please contact barseghyangor8@gmail.com.
With nginx-python, deploying your Python web applications has never been easier. Simplify your server configuration and focus on building great applications!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file nginx_python-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: nginx_python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54845a928fa9b3d90bbe93763952258b89d911469645ac8cc26d4aa4261ee30f |
|
MD5 | 157101ac9f0e20daf1161c0536793f42 |
|
BLAKE2b-256 | 9f2869f702ad623cb0d60f1463487cad154c719bbf6f4c688a4f18dc2d3eb1c8 |