Skip to main content

A more traditional web server

Project description

A more traditional web server in Python

Release Status Documentation Status Build Status

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minipyp-0.2.0a1.tar.gz (20.5 kB view details)

Uploaded Source

File details

Details for the file minipyp-0.2.0a1.tar.gz.

File metadata

  • Download URL: minipyp-0.2.0a1.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for minipyp-0.2.0a1.tar.gz
Algorithm Hash digest
SHA256 174bf40889157d740a8c33fcba6c7c1c47cc45e9d952ba3d7530ad7ca32cd20f
MD5 1c2a818c2c3d99556cf9daaa5a235a33
BLAKE2b-256 181c2d4b8d45b9871aa196f23bc6617fd489e9c8002806c042715829f424d1f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page