Plain is headed towards 1.0! Subscribe for development updates →

Plain

Plain is a web framework for building products with Python.

The core plain package provides the backbone of a Python web application (similar to Flask), while the additional first-party packages can power a more fully-featured database-backed app (similar to Django).

All Plain packages are designed to work together and use PEP 420 to share the plain namespace.

To quickly get started with Plain, visit plainframework.com/start/.

Core Modules

The plain package includes everything you need to start handling web requests with Python:

  • assets - Serve static files and assets.
  • cli - The plain CLI, powered by Click.
  • csrf - Cross-Site Request Forgery protection.
  • forms - HTML forms and form validation.
  • http - HTTP request and response handling.
  • logs - Logging configuration and utilities.
  • preflight - Preflight checks for your app.
  • runtime - Runtime settings and configuration.
  • templates - Jinja2 templates and rendering.
  • test - Test utilities and fixtures.
  • urls - URL routing and request dispatching.
  • views - Class-based views and request handlers.

Foundational Packages

Auth Packages

Admin Packages

Dev Packages

Frontend Packages

 1from pprint import pformat
 2
 3from markupsafe import Markup, escape
 4
 5from plain.http import Response
 6from plain.views.exceptions import ResponseException
 7
 8
 9def dd(*objs):
10    """
11    Dump and die.
12
13    Dump the object and raise a ResponseException with the dump as the response content.
14    """
15
16    print(f"Dumping objects:\n{'\n'.join([pformat(obj) for obj in objs])}")
17
18    dump_strs = [
19        Markup("<pre><code>") + escape(pformat(obj)) + Markup("</code></pre>")
20        for obj in objs
21    ]
22    combined_dump_str = Markup("\n\n").join(dump_strs)
23
24    response = Response()
25    response.status_code = 500
26    response.content = combined_dump_str
27    response.content_type = "text/html"
28    raise ResponseException(response)