Bottle is a fast, lightweight, and simple WSGI micro-framework for small web-applications. It provides routing, templating, and basic utilities in a single file, making it ideal for prototyping and small services. The current stable version is 0.13.4, with releases occurring infrequently, often focusing on Python version compatibility and minor fixes rather than new features.
pip install bottleVerified import paths — ran on the pinned version, not inferred.
This quickstart defines a simple route that takes a name parameter and renders a basic HTML template using Bottle's built-in `SimpleTemplate` engine. It then starts a development server on `127.0.0.1:8080`. Note the explicit host for `run()` due to changes in Bottle 0.13.
Ensure your project's Python interpreter is version 3.7 or newer before upgrading to Bottle 0.13.x.
If you need your development server to be accessible from other machines, explicitly specify `host='0.0.0.0'` in your `run()` call (e.g., `run(host='0.0.0.0', port=8080)`).
Always access `request` and `response` within route handlers or functions called from within a handler where a request context is active. Do not try to store or access them globally outside of a request.
For production environments, deploy your Bottle application with a robust WSGI server such as Gunicorn, uWSGI, or CherryPy.
Install the bottle library using pip: `pip install bottle` or `pip3 install bottle` if you have multiple Python versions. Ensure your virtual environment is active if you are using one.
Ensure the template file exists at the specified path relative to where your Bottle application is run. You can explicitly add template directories to Bottle's search path using `bottle.TEMPLATE_PATH.insert(0, '/path/to/your/templates')` or use an absolute path.
Call the `template` function directly from the `bottle` module: `from bottle import template` and then `template('my_template', **kwargs)` or `bottle.template('my_template', **kwargs)` if not imported directly.Verify the URL being accessed matches a defined `@route()` decorator. Check for typos in the URL or route string, ensure the HTTP method (GET, POST, etc.) is correct, and if using dynamic routes, confirm the syntax (e.g., `<name:int>`). If deployed with WSGI, verify the application's base path.
Ensure your WSGI entry point function correctly accepts the `environ` and `start_response` arguments, even if it just delegates to `bottle.default_app()`. For example, `def wsgi_app(environ, start_response): return bottle.default_app()(environ, start_response)`. Or, if using an application factory pattern, call the factory with `gunicorn 'app:wsgi_app()'`.
No dependency data recorded yet.