Plain
Plain is a web framework for building products with Python.
With the core plain
package you can build an app that:
- Matches URL patterns to Python views
- Handles HTTP requests and responses
- Renders HTML templates with Jinja
- Processes user input via forms
- Has a CLI interface
- Serves static assets (CSS, JS, images)
- Can be modified with middleware
- Integrates first-party and third-party packages
- Has a preflight check system
With the official Plain ecosystem packages you can:
- Integrate a full-featured database ORM
- Use a built-in user authentication system
- Lint and format code
- Run a database-backed cache
- Send emails
- Streamline local development
- Manage feature flags
- Integrate HTMX
- Style with Tailwind CSS
- Add OAuth login and API access
- Run tests with pytest
- Run a background job worker
- Build staff tooling and admin dashboards
Learn more at plainframework.com.
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 dump_strs = [
16 Markup("<pre><code>") + escape(pformat(obj)) + Markup("</code></pre>")
17 for obj in objs
18 ]
19 combined_dump_str = Markup("\n\n").join(dump_strs)
20
21 print(f"Dumping objects:\n{combined_dump_str}")
22
23 response = Response()
24 response.status_code = 500
25 response.content = combined_dump_str
26 response.content_type = "text/html"
27 raise ResponseException(response)