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.

Filename, size & hash SHA256 hash help File type Python version Upload date
minipyp-0.2.0a1.tar.gz (20.5 kB) Copy SHA256 hash SHA256 Source None Feb 4, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page