{ "info": { "author": "Michael Herman", "author_email": "hermanmu@gmail.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 3.6" ], "description": "\n# Bumbo: Python Web Framework built for learning purposes\n\n\n\n\nBumbo is a Python web framework built for learning purposes.\n\nIt'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 \nThis 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": "bumbo3", "package_url": "https://pypi.org/project/bumbo3/", "platform": "", "project_url": "https://pypi.org/project/bumbo3/", "project_urls": null, "release_url": "https://pypi.org/project/bumbo3/0.0.2/", "requires_dist": [ "Jinja2 (==2.10.3)", "parse (==1.12.1)", "requests (==2.22.0)", "requests-wsgi-adapter (==0.4.1)", "WebOb (==1.8.5)", "whitenoise (==4.1.4)" ], "requires_python": ">=3.6.0", "summary": "Bumbo Python Web Framework built for learning purposes.", "version": "0.0.2" }, "last_serial": 5980297, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "c4697d619115d3278b5c81d58a6a0860", "sha256": "998d8c2d7fda3f10939ba22907130ae1911492c1a300600cb7e2313b04370ead" }, "downloads": -1, "filename": "bumbo3-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c4697d619115d3278b5c81d58a6a0860", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 3510, "upload_time": "2019-10-15T21:49:27", "url": "https://files.pythonhosted.org/packages/6f/6b/75b1b4e7f68411688a712b0b1c1ebcb301068a02050ae58032630935852f/bumbo3-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d54ca5eae7a89982482eb3b8f1f9cbd4", "sha256": "3214e6e4a49f3bcaf5e9ab5453fedf27a4d90f9f7d56e22515d5240c3e62b260" }, "downloads": -1, "filename": "bumbo3-0.0.1.tar.gz", "has_sig": false, "md5_digest": "d54ca5eae7a89982482eb3b8f1f9cbd4", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 3059, "upload_time": "2019-10-15T21:49:29", "url": "https://files.pythonhosted.org/packages/5b/48/b3a41cfad4e5a1e961287163ec2732256af31ee174152577459318e85727/bumbo3-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "759582c3bdf098c0db43e958d3356530", "sha256": "8fb9c2428b1a1d0ac2051496e60ab281d9bccbe0a574ff631ddcd55e73110260" }, "downloads": -1, "filename": "bumbo3-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "759582c3bdf098c0db43e958d3356530", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 4924, "upload_time": "2019-10-15T23:00:31", "url": "https://files.pythonhosted.org/packages/fd/b8/a7befe3c4cbdd0efe8bbea5827abaac06ced8c81e886fca5a1614d7fbee9/bumbo3-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "036860748f1f623a84e05433fd900929", "sha256": "e2dc1356e27204a02f47ad4697814cc7c656b83d5e8fc4b9222a7c5aa983b551" }, "downloads": -1, "filename": "bumbo3-0.0.2.tar.gz", "has_sig": false, "md5_digest": "036860748f1f623a84e05433fd900929", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 4892, "upload_time": "2019-10-15T23:00:34", "url": "https://files.pythonhosted.org/packages/92/5d/3a1a7a24bb3a32965f321512869c0a3d1e43ede4b85ca7628e7f74825d25/bumbo3-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "759582c3bdf098c0db43e958d3356530", "sha256": "8fb9c2428b1a1d0ac2051496e60ab281d9bccbe0a574ff631ddcd55e73110260" }, "downloads": -1, "filename": "bumbo3-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "759582c3bdf098c0db43e958d3356530", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 4924, "upload_time": "2019-10-15T23:00:31", "url": "https://files.pythonhosted.org/packages/fd/b8/a7befe3c4cbdd0efe8bbea5827abaac06ced8c81e886fca5a1614d7fbee9/bumbo3-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "036860748f1f623a84e05433fd900929", "sha256": "e2dc1356e27204a02f47ad4697814cc7c656b83d5e8fc4b9222a7c5aa983b551" }, "downloads": -1, "filename": "bumbo3-0.0.2.tar.gz", "has_sig": false, "md5_digest": "036860748f1f623a84e05433fd900929", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 4892, "upload_time": "2019-10-15T23:00:34", "url": "https://files.pythonhosted.org/packages/92/5d/3a1a7a24bb3a32965f321512869c0a3d1e43ede4b85ca7628e7f74825d25/bumbo3-0.0.2.tar.gz" } ] }