{ "info": { "author": "Jahongir Rahmonov", "author_email": "jrahmonov2@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": "bumbo2", "package_url": "https://pypi.org/project/bumbo2/", "platform": "", "project_url": "https://pypi.org/project/bumbo2/", "project_urls": null, "release_url": "https://pypi.org/project/bumbo2/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": 5612568, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "1dfa85093293d5dbf85cdbbd26111710", "sha256": "694738c3bb2f46a820cda8e84c0109f1694923c92ccffb6b31632ff1401a4687" }, "downloads": -1, "filename": "bumbo2-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "1dfa85093293d5dbf85cdbbd26111710", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 3476, "upload_time": "2019-07-31T09:47:24", "url": "https://files.pythonhosted.org/packages/8f/75/0f6d77149eba7e7e58d8aeca0bc84e90be0fb12bf8394c2631c4112820d0/bumbo2-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9289dd2862196163c8b9a4ff4ecf369c", "sha256": "07dba6bce3cf1f05b2d335ca220d503ff4356cef900afee9a8771b96de33feda" }, "downloads": -1, "filename": "bumbo2-0.0.1.tar.gz", "has_sig": false, "md5_digest": "9289dd2862196163c8b9a4ff4ecf369c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 3047, "upload_time": "2019-07-31T09:47:27", "url": "https://files.pythonhosted.org/packages/6a/29/39163c7f9038cd83792904bb8ab85772336acb8ae070c45e07020bf17471/bumbo2-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "5aa23bb4cdd4af7246c75e3d9f53649f", "sha256": "3158cec557fbb4bcc1aed39b241ed181e82c48b409dc2ab5286f6d47c9b7e8dc" }, "downloads": -1, "filename": "bumbo2-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "5aa23bb4cdd4af7246c75e3d9f53649f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 4889, "upload_time": "2019-07-31T09:56:49", "url": "https://files.pythonhosted.org/packages/c4/8e/e04226a44859a30167e5219541b6a78190fe6ae90c51ae458b8a92170c81/bumbo2-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "86ed2602ab178656e04b75a34777899e", "sha256": "b1827991783b638f00becc0b5ce8f74aef420879954830277b781b6e23ebe16f" }, "downloads": -1, "filename": "bumbo2-0.0.2.tar.gz", "has_sig": false, "md5_digest": "86ed2602ab178656e04b75a34777899e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 4868, "upload_time": "2019-07-31T09:56:52", "url": "https://files.pythonhosted.org/packages/db/f5/5ab5cea2e3f250bbc8915a8bf31978434eeff60b9ffac35b568cf3250f2f/bumbo2-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5aa23bb4cdd4af7246c75e3d9f53649f", "sha256": "3158cec557fbb4bcc1aed39b241ed181e82c48b409dc2ab5286f6d47c9b7e8dc" }, "downloads": -1, "filename": "bumbo2-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "5aa23bb4cdd4af7246c75e3d9f53649f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 4889, "upload_time": "2019-07-31T09:56:49", "url": "https://files.pythonhosted.org/packages/c4/8e/e04226a44859a30167e5219541b6a78190fe6ae90c51ae458b8a92170c81/bumbo2-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "86ed2602ab178656e04b75a34777899e", "sha256": "b1827991783b638f00becc0b5ce8f74aef420879954830277b781b6e23ebe16f" }, "downloads": -1, "filename": "bumbo2-0.0.2.tar.gz", "has_sig": false, "md5_digest": "86ed2602ab178656e04b75a34777899e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 4868, "upload_time": "2019-07-31T09:56:52", "url": "https://files.pythonhosted.org/packages/db/f5/5ab5cea2e3f250bbc8915a8bf31978434eeff60b9ffac35b568cf3250f2f/bumbo2-0.0.2.tar.gz" } ] }