gitmyhub

bottle

Python ★ 8.8k updated 2mo ago

bottle.py is a fast and simple micro-framework for python web-applications.

Bottle is a tiny Python web framework that fits in a single file with no external dependencies, define URL routes and serve web responses in a handful of lines.

PythonWSGIsetup: easycomplexity 2/5

Bottle is a minimal Python web framework for building web applications and APIs. It is distributed as a single Python file with no external dependencies, meaning you can drop one file into a project directory and start using it immediately without installing anything beyond Python itself.

The framework handles the fundamental tasks of a web server. You define URL routes by decorating Python functions, and Bottle calls those functions when a matching request arrives. URLs can include variable parts, so a single route like "/hello/" will match any name and pass it to the function as an argument. Bottle also includes a built-in template engine for generating HTML, though it works with popular third-party engines like Jinja2 and Mako if you prefer those.

Other built-in tools cover reading form data, handling file uploads, working with cookies, and accessing HTTP headers. For running the application, Bottle ships a simple development server sufficient for testing, and it supports connecting to production-grade WSGI servers like Gunicorn or CherryPy's Cheroot for real deployments.

A working Hello World example is a handful of lines: import a couple of names, decorate a function with a route, and call run. The framework targets situations where a larger, more opinionated framework would be more than the project needs. It does not include a built-in database layer, admin panel, or authentication system.

Installation is one pip command. The code and documentation are available under the MIT license.

Where it fits