{ "info": { "author": "Michael Herman", "author_email": "michael@testdriven.io", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 3.6" ], "description": "\n# Bumbo: Python Web Framework built for learning purposes\n\n![purpose](https://img.shields.io/badge/purpose-learning-green.svg)\n![PyPI](https://img.shields.io/pypi/v/bumbo_testing.svg)\n\nBumbo is a Python web framework built for learning purposes. It's a WSGI framework and can be used with any WSGI application server such as Gunicorn.\n\n## Installation\n\n```shell\npip install bumbo\n```\n\n## How to use it\n\n### Basic usage:\n\n```python\nfrom bumbo.api import API\n\napp = API()\n\n\n@app.route(\"/home\")\ndef home(request, response):\n response.text = \"Hello from the HOME page\"\n\n\n@app.route(\"/hello/{name}\")\ndef greeting(request, response, name):\n response.text = f\"Hello, {name}\"\n\n\n@app.route(\"/book\")\nclass BooksResource:\n def get(self, req, resp):\n resp.text = \"Books Page\"\n\n def post(self, req, resp):\n resp.text = \"Endpoint to create a book\"\n\n\n@app.route(\"/template\")\ndef template_handler(req, resp):\n resp.body = app.template(\n \"index.html\", context={\"name\": \"Bumbo\", \"title\": \"Best Framework\"}).encode()\n```\n\n### Unit Tests\n\nThe recommended way of writing unit tests is with [pytest](https://docs.pytest.org/en/latest/). There are two built in fixtures\nthat you may want to use when writing unit tests with Bumbo. The first one is `app` which is an instance of the main `API` class:\n\n```python\ndef test_route_overlap_throws_exception(app):\n @app.route(\"/\")\n def home(req, resp):\n resp.text = \"Welcome Home.\"\n\n with pytest.raises(AssertionError):\n @app.route(\"/\")\n def home2(req, resp):\n resp.text = \"Welcome Home2.\"\n```\n\nThe other one is `client` that you can use to send HTTP requests to your handlers. It is based on the famous [requests](http://docs.python-requests.org/en/master/) and it should feel very familiar:\n\n```python\ndef test_parameterized_route(app, client):\n @app.route(\"/{name}\")\n def hello(req, resp, name):\n resp.text = f\"hey {name}\"\n\n assert client.get(\"http://testserver/matthew\").text == \"hey matthew\"\n```\n\n## Templates\n\nThe default folder for templates is `templates`. You can change it when initializing the main `API()` class:\n\n```python\napp = API(templates_dir=\"templates_dir_name\")\n```\n\nThen you can use HTML files in that folder like so in a handler:\n\n```python\n@app.route(\"/show/template\")\ndef handler_with_template(req, resp):\n resp.html = app.template(\n \"example.html\", context={\"title\": \"Awesome Framework\", \"body\": \"welcome to the future!\"})\n```\n\n## Static Files\n\nJust like templates, the default folder for static files is `static` and you can override it:\n\n```python\napp = API(static_dir=\"static_dir_name\")\n```\n\nThen you can use the files inside this folder in HTML files:\n\n```html\n\n\n\n\n \n {{title}}\n\n \n\n\n\n

{{body}}

\n

This is a paragraph

\n\n\n```\n\n### Middleware\n\nYou can create custom middleware classes by inheriting from the `bumbo.middleware.Middleware` class and overriding its two methods\nthat are called before and after each request:\n\n```python\nfrom bumbo.api import API\nfrom bumbo.middleware import Middleware\n\n\napp = API()\n\n\nclass SimpleCustomMiddleware(Middleware):\n def process_request(self, req):\n print(\"Before dispatch\", req.url)\n\n def process_response(self, req, res):\n print(\"After dispatch\", req.url)\n\n\napp.add_middleware(SimpleCustomMiddleware)\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "bumbo-testing", "package_url": "https://pypi.org/project/bumbo-testing/", "platform": "", "project_url": "https://pypi.org/project/bumbo-testing/", "project_urls": null, "release_url": "https://pypi.org/project/bumbo-testing/0.0.2/", "requires_dist": [ "Jinja2 (==2.10.1)", "requests-wsgi-adapter (==0.4.1)", "parse (==1.12.0)", "requests (==2.22.0)", "WebOb (==1.8.5)", "whitenoise (==4.1.2)" ], "requires_python": ">=3.6.0", "summary": "Bumbo Python Web Framework built for learning purposes.", "version": "0.0.2" }, "last_serial": 5470895, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "b8d68ba3c305796c85bef0da073d0db9", "sha256": "a3680045639c02bf9d41b38e02533d1c3b2cee50804d990f6bab2fea4ce891c5" }, "downloads": -1, "filename": "bumbo_testing-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "b8d68ba3c305796c85bef0da073d0db9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 3681, "upload_time": "2019-07-01T01:11:09", "url": "https://files.pythonhosted.org/packages/bf/1b/7ae271f7f866681d7193a605ceb922db69158fd8779b34b454a62743cf14/bumbo_testing-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b5bbe3c186e1be790c4ff9b0f91200a3", "sha256": "c2f4e9f3a14cf12157f33196ffcb5dba470ad5d0aea6c260fa08655a2193b8e4" }, "downloads": -1, "filename": "bumbo_testing-0.0.1.tar.gz", "has_sig": false, "md5_digest": "b5bbe3c186e1be790c4ff9b0f91200a3", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 3077, "upload_time": "2019-07-01T01:11:11", "url": "https://files.pythonhosted.org/packages/f0/4e/502aeabc139a6c862f04f881ac2ee8301ddace17b628de627ae9fdd947a6/bumbo_testing-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "d5e8d24b47528aa22c23582e69795dd8", "sha256": "37ac431696d01705170871bddd4347de7067276a1ab0a2f8a7a4258ba0b7e9f4" }, "downloads": -1, "filename": "bumbo_testing-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "d5e8d24b47528aa22c23582e69795dd8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 5094, "upload_time": "2019-07-01T12:49:02", "url": "https://files.pythonhosted.org/packages/a0/38/5d198b8b84fbabc2a29a35acd8df2a481bce1c69c20ed3ec18a407cf62be/bumbo_testing-0.0.2-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d5e8d24b47528aa22c23582e69795dd8", "sha256": "37ac431696d01705170871bddd4347de7067276a1ab0a2f8a7a4258ba0b7e9f4" }, "downloads": -1, "filename": "bumbo_testing-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "d5e8d24b47528aa22c23582e69795dd8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 5094, "upload_time": "2019-07-01T12:49:02", "url": "https://files.pythonhosted.org/packages/a0/38/5d198b8b84fbabc2a29a35acd8df2a481bce1c69c20ed3ec18a407cf62be/bumbo_testing-0.0.2-py3-none-any.whl" } ] }