{ "info": { "author": "Jahongir Rahmonov", "author_email": "jrahmonov2@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "\n
\n
\n
This is a paragraph
\n\n\n```\n\n## Custom Exception Handler\n\nSometimes, depending on the exception raised, you may want to do a certain action. For such cases, you can register an exception handler:\n\n```python\ndef on_exception(req, resp, exception):\n if isinstance(exception, HTTPError):\n if exception.status == 404:\n resp.text = \"Unfortunately the thing you were looking for was not found\"\n else:\n resp.text = str(exception)\n else:\n # unexpected exceptions\n if app.debug:\n debug_exception_handler(req, resp, exception)\n else:\n print(\"These unexpected exceptions should be logged.\")\n\napp = Alcazar(debug=False)\napp.add_exception_handler(on_exception)\n```\n\nThis exception handler will catch 404 HTTPErrors and change the text to `\"Unfortunately the thing you were looking for was not found\"`. For other HTTPErrors, it will simply\nshow the exception message. If the raised exception is not an HTTPError and if `debug` is set to True, it will show the exception and its traceback. Otherwise, it will log it.\n\n## Middleware\n\nYou can create custom middleware classes by inheriting from the `alcazar.middleware.Middleware` class and override its two methods\nthat are called before and after each request:\n\n```python\nfrom alcazar import Alcazar\nfrom alcazar.middleware import Middleware\n\napp = Alcazar()\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## Features\n\n- WSGI compatible\n- Basic and parameterized routing\n- Class based handlers\n- Test Client\n- Support for templates\n- Support for static files\n- Custom exception handler\n- Middleware\n\n## Note\n\nIt is extremely raw and will hopefully keep improving. If you are interested in knowing how a particular feature is implemented in other\nframeworks, please open an issue and we will hopefully implement and explain it in a blog post.\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": "https://github.com/rahmonov/alcazar", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "alcazar-web-framework", "package_url": "https://pypi.org/project/alcazar-web-framework/", "platform": "", "project_url": "https://pypi.org/project/alcazar-web-framework/", "project_urls": { "Homepage": "https://github.com/rahmonov/alcazar" }, "release_url": "https://pypi.org/project/alcazar-web-framework/0.0.2/", "requires_dist": [ "Jinja2 (==2.10)", "requests-wsgi-adapter (==0.4.0)", "parse (==1.11.1)", "requests (==2.21.0)", "WebOb (==1.8.5)", "whitenoise (==4.1.2)" ], "requires_python": ">=3.6.0", "summary": "Python Web Framework built for learning purposes.", "version": "0.0.2" }, "last_serial": 5117251, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "100b8d298982cf5d10d088cd44762dc9", "sha256": "bdab8928063d1421c6bd41077e9eb54f62a610a870e2211164c735afe05252e6" }, "downloads": -1, "filename": "alcazar_web_framework-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "100b8d298982cf5d10d088cd44762dc9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 9571, "upload_time": "2019-04-09T07:03:39", "url": "https://files.pythonhosted.org/packages/ce/ae/25f103ebad24d637ef0af8c9510c4711a3e918e675bc810d550437230a29/alcazar_web_framework-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9699aeed803da998af468ff3bf29308f", "sha256": "327775c040fdc674f776ced0466d05a38a7f741dd47c2650fc25176e93c897e1" }, "downloads": -1, "filename": "alcazar-web-framework-0.0.2.tar.gz", "has_sig": false, "md5_digest": "9699aeed803da998af468ff3bf29308f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 9556, "upload_time": "2019-04-09T07:03:41", "url": "https://files.pythonhosted.org/packages/8f/7a/ff3696446a1ba8144368e5186c9b323ba027be4c3a29d9ecd20a8efef629/alcazar-web-framework-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "100b8d298982cf5d10d088cd44762dc9", "sha256": "bdab8928063d1421c6bd41077e9eb54f62a610a870e2211164c735afe05252e6" }, "downloads": -1, "filename": "alcazar_web_framework-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "100b8d298982cf5d10d088cd44762dc9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 9571, "upload_time": "2019-04-09T07:03:39", "url": "https://files.pythonhosted.org/packages/ce/ae/25f103ebad24d637ef0af8c9510c4711a3e918e675bc810d550437230a29/alcazar_web_framework-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9699aeed803da998af468ff3bf29308f", "sha256": "327775c040fdc674f776ced0466d05a38a7f741dd47c2650fc25176e93c897e1" }, "downloads": -1, "filename": "alcazar-web-framework-0.0.2.tar.gz", "has_sig": false, "md5_digest": "9699aeed803da998af468ff3bf29308f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 9556, "upload_time": "2019-04-09T07:03:41", "url": "https://files.pythonhosted.org/packages/8f/7a/ff3696446a1ba8144368e5186c9b323ba027be4c3a29d9ecd20a8efef629/alcazar-web-framework-0.0.2.tar.gz" } ] }