This release is a pre-release and may not be stable for production use.
A more traditional web server in Python
About the project
MiniPyP (pronounced mini·pipe) is an event-driven web server written in pure Python. However, MiniPyP is not an application framework. It’s a full web server, with virtual hosts, reverse proxies, and everything else you need. MiniPyP is intended to replace Apache and nginx, so you can use Python without the performance hit of CGI.
MiniPyP has some more advanced features right out of the box, too. For example, when a user goes to /some/url on your server, and the directory’s static option is set to False (default), the server will look for the file /some/url. If it doesn’t exist, but the file /some does, that file will be served. Extensions do not need to be specified with the static option set to False. In addition, if a file does not exist but a file named catchall exists, it will be served instead of a 404. This makes creating a single-page application that much more elegant.
Setup
First, install MiniPyP via pip.
pip install minipyp
To start a server within a Python program, specify a config like so (you may alternatively give a file location as the config):
from minipyp import MiniPyP
config = {
'host': '0.0.0.0',
'port': 80,
'root': '/var/www/html',
'timeout': 15,
'error_pages': {
404: {
'html': '<p>The file <code>{uri}</code> could not be found.</p>'
}
}
}
MiniPyP(config=config).start()
You may also start a server via the command line. Unless specified, the config will be created and loaded from /etc/minipyp/minipyp.conf on Mac/Linux and %APPDATA%\MiniPyP\minipyp.conf on Windows.
minipyp start [-c CONFIG]
Creating a page
To create a page (e.g. ‘https://mysite.com/test’), create a file called test.py in mysite.com’s root with the following:
def render(server, request):
return '<p>You requested the page <code>' + request.uri + '</code>.</p>'
Learn more
See the full documentation at https://minipyp.readthedocs.io
History
0.2.0
Daemon mode
Logging (+ log files)
Global config file (minipyp.conf)
Directory-specific config files (.minipyp)
0.1.0b1
Now tracking changes
Metadata
Release files for minipyp 0.2.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| minipyp-0.2.0a1.tar.gz | 20.5 kB | Details |
Release files / minipyp-0.2.0a1.tar.gz
| Download URL | minipyp-0.2.0a1.tar.gz |
|---|---|
| Size | 20.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
174bf40889157d740a8c33fcba6c7c1c47cc45e9d952ba3d7530ad7ca32cd20f
|
|
BLAKE2b-256 checksum How to use checksums |
181c2d4b8d45b9871aa196f23bc6617fd489e9c8002806c042715829f424d1f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |