{ "info": { "author": "Roberto Prevato", "author_email": "roberto.prevato@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: AsyncIO", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.7" ], "description": "[](https://dev.azure.com/robertoprevato/BlackSheep/_build/latest?definitionId=7) [](https://pypi.org/project/BlackSheep/)\n\n# BlackSheep\nBlackSheep is an asynchronous web framework to build event based, non-blocking Python web applications.\nIt is inspired by [Flask](https://palletsprojects.com/p/flask/), [ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/), and the work by [Yury Selivanov](https://magic.io/blog/uvloop-blazing-fast-python-networking/).\n\n
\n\n```bash\npip install blacksheep\n```\n\n---\n\n```python\nfrom datetime import datetime\nfrom blacksheep.server import Application\nfrom blacksheep.server.responses import text\n\n\napp = Application()\n\n@app.route('/')\nasync def home(request):\n return text(f'Hello, World! {datetime.utcnow().isoformat()}')\n\n```\n\n## Getting started\nUse these project templates to get started:\n\n* [BlackSheep MVC project template](https://github.com/RobertoPrevato/BlackSheepMVC)\n* [BlackSheep empty project template](https://github.com/RobertoPrevato/BlackSheepEmptyProject)\n\n## Requirements\n\nBlackSheep belongs to the category of [ASGI](https://asgi.readthedocs.io/en/latest/) web frameworks, so it requires an ASGI HTTP server to run, such as [uvicorn](http://www.uvicorn.org/), [daphne](https://github.com/django/daphne/), or [hypercorn](https://pgjones.gitlab.io/hypercorn/). For example, to use it with uvicorn:\n\n```bash\n$ pip install uvicorn\n```\n\nTo run an application like in the example above, use the methods provided by the ASGI HTTP Server:\n\n```bash\n# NB: if the BlackSheep app is defined in a file `server.py`\n\n$ uvicorn server:app\n```\n\nTo run for production, refer to the documentation of the chosen ASGI server (i.e. for [uvicorn](https://www.uvicorn.org/#running-with-gunicorn)).\n\n## Automatic bindings and dependency injection\nBlackSheep supports automatic binding of values for request handlers, by type annotation or by conventions. See [more here](https://github.com/RobertoPrevato/BlackSheep/wiki/Model-binding).\n```python\nfrom blacksheep.server.bindings import (FromJson,\n FromHeader,\n FromQuery,\n FromRoute,\n FromServices)\n\n@app.router.put(b'/:d')\nasync def example(a: FromQuery(List[str]),\n b: FromServices(Dog),\n c: FromJson(Cat),\n d: FromRoute(),\n e: FromHeader(name='X-Example')):\n ...\n\n\n@app.router.get(b'/:culture_code/:area')\nasync def home(request, culture_code, area):\n return text(f'Request for: {culture_code} {area}')\n```\nIt also supports dependency injection, provided by [rodi](https://github.com/RobertoPrevato/rodi), a library from the same author, supporting `singleton`, `scoped`, and `transient` life style for activated services.\n\n## Strategies to handle authentication and authorization\nBlackSheep implements strategies to handle authentication and authorization, using [GuardPost](https://github.com/RobertoPrevato/GuardPost), a library from the same author.\n\n```python\napp.use_authentication()\\\n .add(ExampleAuthenticationHandler())\n\n\napp.use_authorization()\\\n .add(AdminsPolicy())\n\n\n@auth('admin')\n@app.router.get(b'/')\nasync def only_for_admins():\n ...\n\n\n@auth()\n@app.router.get(b'/')\nasync def only_for_authenticated_users():\n ...\n```\n\n## Objectives\n* Intelligible and easy to learn API, similar to those of many Python web frameworks\n* Rich code API, based on Dependency Injection and inspired by ASP.NET Core\n* Keep the core package minimal and focused, as much as possible, on features defined in HTTP and HTML standards\n* Targeting stateless applications to be deployed in the cloud\n* [High performance, see results from TechEmpower benchmarks (links in Wiki page)](https://github.com/RobertoPrevato/BlackSheep/wiki/Server-performance)\n\n## Web framework features\n* [ASGI compatibility](https://asgi.readthedocs.io/en/latest/)\n* [Routing](https://github.com/RobertoPrevato/BlackSheep/wiki/Routing)\n* [Request handlers defined as functions, or class methods](https://github.com/RobertoPrevato/BlackSheep/wiki/Defining-request-handlers)\n* [Middlewares](https://github.com/RobertoPrevato/BlackSheep/wiki/Middlewares)\n* [Built-in support for dependency injection](https://github.com/RobertoPrevato/BlackSheep/wiki/Dependency-injection)\n* [Support for automatic binding of route and query parameters to request handlers methods calls](https://github.com/RobertoPrevato/BlackSheep/wiki/Handlers-normalization#route-parameters)\n* [Strategy to handle exceptions](https://github.com/RobertoPrevato/BlackSheep/wiki/Exceptions-handling)\n* [Strategy to handle authentication and authorization](https://github.com/RobertoPrevato/BlackSheep/wiki/Authentication-and-authorization-strategies)\n* [Handlers normalization](https://github.com/RobertoPrevato/BlackSheep/wiki/Handlers-normalization)\n* [Chunked encoding](https://github.com/RobertoPrevato/BlackSheep/wiki/Chunked-encoding) through generators (yield syntax)\n* [Serving static files](https://github.com/RobertoPrevato/BlackSheep/wiki/Serving-static-files)\n* [Integration with Jinja2](https://github.com/RobertoPrevato/BlackSheep/wiki/Jinja2)\n\n## Client features\n* [HTTP connection pooling](https://github.com/RobertoPrevato/BlackSheep/wiki/Connection-pooling)\n* User friendly [handling of SSL contexts](https://github.com/RobertoPrevato/BlackSheep/wiki/Client-handling-SSL-contexts) (safe by default)\n* Support for [client side middlewares](https://github.com/RobertoPrevato/BlackSheep/wiki/Client-middlewares), enabling clean source code and separation of concerns (logging of different kinds, handling of cookies, etc.)\n* Automatic handling of redirects (can be disabled, validates circular redirects and maximum number of redirects - redirects to URN are simply returned to code using the client)\n* Automatic handling of cookies (can be disabled, `Set-Cookie` and `Cookie` headers)\n\n**Example:**\n```python\nimport asyncio\nfrom blacksheep.client import ClientSession\n\n\nasync def client_example(loop):\n async with ClientSession() as client:\n response = await client.get('https://docs.python.org/3/')\n\n assert response is not None\n text = await response.text()\n print(text)\n\n\nloop = asyncio.get_event_loop()\nloop.run_until_complete(client_example(loop))\n\n```\n\n## Documentation\nPlease refer to the [project Wiki](https://github.com/RobertoPrevato/BlackSheep/wiki).", "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/RobertoPrevato/BlackSheep", "keywords": "BlackSheep web framework", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "blacksheep", "package_url": "https://pypi.org/project/blacksheep/", "platform": "*nix", "project_url": "https://pypi.org/project/blacksheep/", "project_urls": { "Homepage": "https://github.com/RobertoPrevato/BlackSheep" }, "release_url": "https://pypi.org/project/blacksheep/0.2.0/", "requires_dist": null, "requires_python": "", "summary": "Fast web framework and HTTP client for Python asyncio", "version": "0.2.0" }, "last_serial": 5963329, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "b401ecc49fb4043ba3e74ea99bd6364b", "sha256": "0fcff154dca55c089db3e35aa03982ea376fbff1c624f6431c1cdfad994a9909" }, "downloads": -1, "filename": "blacksheep-0.0.1.tar.gz", "has_sig": false, "md5_digest": "b401ecc49fb4043ba3e74ea99bd6364b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 482699, "upload_time": "2018-11-24T18:30:40", "url": "https://files.pythonhosted.org/packages/30/73/0b82629d584101ffc05b37e35917b9e545b951de9598e0e7c1cf6a3f21e8/blacksheep-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "d7be9815ab5b3cf6872be9980209cb2f", "sha256": "ca6b603774c80a995c739aa1c6dd05782cad1e037af046233690c384017640fa" }, "downloads": -1, "filename": "blacksheep-0.0.2.tar.gz", "has_sig": false, "md5_digest": "d7be9815ab5b3cf6872be9980209cb2f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 578647, "upload_time": "2018-11-25T19:05:34", "url": "https://files.pythonhosted.org/packages/e2/7d/42f811033edcd615d908a2192f0fefdfad7f3460f5e2dff171985a0a2a9f/blacksheep-0.0.2.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "0e09454c0f5ea76860aaad6e0097bcdd", "sha256": "a99577e39a9ee3e05deb27c437aa2b36bef80b2c5a43a99d6911e79f134ce644" }, "downloads": -1, "filename": "blacksheep-0.0.4.tar.gz", "has_sig": false, "md5_digest": "0e09454c0f5ea76860aaad6e0097bcdd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 753464, "upload_time": "2018-12-30T14:53:34", "url": "https://files.pythonhosted.org/packages/78/dd/37fe62619ba7750784afbbdb28b03d63132aaba36083d9ef2e53780ee8b4/blacksheep-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "4b7783e2f61860c4072b9c6e96dcd2e3", "sha256": "1f19c885940ee4b549ad32369ab40dad999fee6cb0d43901120c94090d030ded" }, "downloads": -1, "filename": "blacksheep-0.0.5.tar.gz", "has_sig": false, "md5_digest": "4b7783e2f61860c4072b9c6e96dcd2e3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 754332, "upload_time": "2019-01-01T01:41:14", "url": "https://files.pythonhosted.org/packages/e5/1b/8c7bd86fcd5f29812e1978e3c1ffe4ecbfebf23a625c38b3e3edd49ee4ba/blacksheep-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "233e0d98852513d476017356c57b1ede", "sha256": "30f86ce34c44eddcd0ec29bcdea144bf0f184abd068e9f5b28d01ccd93125777" }, "downloads": -1, "filename": "blacksheep-0.0.6.tar.gz", "has_sig": false, "md5_digest": "233e0d98852513d476017356c57b1ede", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 669693, "upload_time": "2019-01-03T06:36:15", "url": "https://files.pythonhosted.org/packages/7d/17/e5ea2934f6ce8cb73b115da5b097d71c2803963ef48d0caba0b58b083bb7/blacksheep-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "eb3c252c4ae19f923331299410796aa9", "sha256": "77026d0d6d3878333b7695415a606c35785f18bd0b0860f0f8c050fdee65be62" }, "downloads": -1, "filename": "blacksheep-0.0.7.tar.gz", "has_sig": false, "md5_digest": "eb3c252c4ae19f923331299410796aa9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 682710, "upload_time": "2019-01-10T07:00:02", "url": "https://files.pythonhosted.org/packages/db/bc/bf785504190e74bb39adb9c541b520cb40d0969c47251abb48661bc6b157/blacksheep-0.0.7.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "6264d4b68824ffda19f4215f6389cd16", "sha256": "1a77a69c33b66adc5f0bf9f7ed21033dc42adc1d8edbbd61168f06a114099589" }, "downloads": -1, "filename": "blacksheep-0.0.9.tar.gz", "has_sig": false, "md5_digest": "6264d4b68824ffda19f4215f6389cd16", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 702782, "upload_time": "2019-05-17T10:30:26", "url": "https://files.pythonhosted.org/packages/13/c7/5bc863c7913d9e301119833d7e019621ab7432178b87dca9be3983d8b630/blacksheep-0.0.9.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "8238d77dba88373b4fff8a732811d168", "sha256": "96289b4760b3a3a14fbed103001f67a7ea8972fb42878f64c7fab76a9ebdd7d9" }, "downloads": -1, "filename": "blacksheep-0.1.0.tar.gz", "has_sig": false, "md5_digest": "8238d77dba88373b4fff8a732811d168", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 709505, "upload_time": "2019-06-10T18:10:11", "url": "https://files.pythonhosted.org/packages/43/1b/2dc8f5959293e023d1952eb4bff5e31e21979209b715d99b8331bfdb35f5/blacksheep-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "3628943725ced1df4df09c6a8e880aba", "sha256": "aaa9033fa0162fa475c2b60e8328c9c12db35e59d8cfd55e6aaab3eeaec2a9ef" }, "downloads": -1, "filename": "blacksheep-0.1.1.tar.gz", "has_sig": false, "md5_digest": "3628943725ced1df4df09c6a8e880aba", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 709737, "upload_time": "2019-06-23T08:23:16", "url": "https://files.pythonhosted.org/packages/e3/12/8337daff794816d66fc3b7129046fd3157f9b1712c7fd429f1f373bdc7f2/blacksheep-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "edb05c46f78c6c193184b0ccbe4a092b", "sha256": "16459722aeb4b020ace9a9ded9f3be870f3bdcbfab74eb8e9653adb3ab6bcb40" }, "downloads": -1, "filename": "blacksheep-0.1.2.tar.gz", "has_sig": false, "md5_digest": "edb05c46f78c6c193184b0ccbe4a092b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 595884, "upload_time": "2019-07-30T13:08:48", "url": "https://files.pythonhosted.org/packages/01/1f/a09d3b36e17f996ea34d2fa939ee960475739bf179ffecf0ee6fc4dcbc0e/blacksheep-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "5c37d41991ccc91e73bd15671f8a8413", "sha256": "4bfeac7bf6e8d0748dfeba76b76783c0532d2daad2bf339b3ca403a5c6548326" }, "downloads": -1, "filename": "blacksheep-0.1.3.tar.gz", "has_sig": false, "md5_digest": "5c37d41991ccc91e73bd15671f8a8413", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 596372, "upload_time": "2019-07-30T16:37:17", "url": "https://files.pythonhosted.org/packages/1f/5b/63ca0c194dc24b9895db31ed9a85f498b42d5181c1b0fdaac225fc198835/blacksheep-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "0cd3ad6e93585d6f5b4003f91947b808", "sha256": "962e47a11f7bead19832053153fd453bc7800128e92cba9a8db63568f6518342" }, "downloads": -1, "filename": "blacksheep-0.1.4.tar.gz", "has_sig": false, "md5_digest": "0cd3ad6e93585d6f5b4003f91947b808", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 596374, "upload_time": "2019-07-30T16:52:31", "url": "https://files.pythonhosted.org/packages/d1/a1/2f591f2ff3e945369bc8cf27c2b54b3cb3f2e7c0ef26453011f0c21f21b9/blacksheep-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "c26bb0bf317d536edab3e28c8a1404eb", "sha256": "be6312555a8d093401930cbe13c133282b232fdd7a49a213ba9bbb3a519764c3" }, "downloads": -1, "filename": "blacksheep-0.1.5.tar.gz", "has_sig": false, "md5_digest": "c26bb0bf317d536edab3e28c8a1404eb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 616771, "upload_time": "2019-08-22T19:24:23", "url": "https://files.pythonhosted.org/packages/c8/2d/598c3b0d162a6192f9a7f7c6e0ac3a9eb8db08b29830b4da3f6c0132c8b8/blacksheep-0.1.5.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "396647d36b198c9af0686140096a9dad", "sha256": "b76ce8c91f8ba0a9830d51b586927fa30dd6594912bcfdffb80f3edd661888bf" }, "downloads": -1, "filename": "blacksheep-0.1.6.tar.gz", "has_sig": false, "md5_digest": "396647d36b198c9af0686140096a9dad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 617022, "upload_time": "2019-08-27T20:20:51", "url": "https://files.pythonhosted.org/packages/3e/69/76f76568278f45de24f85ff22c0e3e305908a3e5118ac9dc4aebf7419370/blacksheep-0.1.6.tar.gz" } ], "0.1.7": [ { "comment_text": "", "digests": { "md5": "d3442776cfa8705c43f1c05e1853782f", "sha256": "d041c8c59f66ac1c42d9a14cc06825432ce15dfa62355e1fd16de775e1e12954" }, "downloads": -1, "filename": "blacksheep-0.1.7.tar.gz", "has_sig": false, "md5_digest": "d3442776cfa8705c43f1c05e1853782f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 617309, "upload_time": "2019-08-28T14:58:51", "url": "https://files.pythonhosted.org/packages/a4/fe/222f6ca704539a9ffd35ab49861934a7e009e08fbfef0b2fe37dd558743e/blacksheep-0.1.7.tar.gz" } ], "0.1.8": [ { "comment_text": "", "digests": { "md5": "e4b64270c9ce69fac97d6cb6bc5f9b4f", "sha256": "1d6508a0a5e864dfb8b9d27fedaf255c30b811f2dbb7abc1219a8c75d496622f" }, "downloads": -1, "filename": "blacksheep-0.1.8.tar.gz", "has_sig": false, "md5_digest": "e4b64270c9ce69fac97d6cb6bc5f9b4f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 619721, "upload_time": "2019-09-29T14:16:31", "url": "https://files.pythonhosted.org/packages/cf/37/b16ea4e6d34cf78ee6263b93246b86150e038369a83fbb756a1508c81925/blacksheep-0.1.8.tar.gz" } ], "0.1.9": [ { "comment_text": "", "digests": { "md5": "53cd19ed9df4a1a9c99956485415034e", "sha256": "c5b95554f8338f1c872b04f99c2e4e7789f5a34704116ecaf0ce2b150e41fe41" }, "downloads": -1, "filename": "blacksheep-0.1.9.tar.gz", "has_sig": false, "md5_digest": "53cd19ed9df4a1a9c99956485415034e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 621882, "upload_time": "2019-10-04T19:58:02", "url": "https://files.pythonhosted.org/packages/6c/e8/0c3112d4bc2d81417f1f0843542deab20bdc1caca83cfb596205f09d6145/blacksheep-0.1.9.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "4c4ceda93ff84ff69bcae8386d29fff9", "sha256": "30443e2e7511c5c17277e1998e5942811fe5bedac962f771c954c26812283a49" }, "downloads": -1, "filename": "blacksheep-0.2.0.tar.gz", "has_sig": false, "md5_digest": "4c4ceda93ff84ff69bcae8386d29fff9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 624405, "upload_time": "2019-10-12T06:40:55", "url": "https://files.pythonhosted.org/packages/e5/db/b7048411409f971ab77d3e20a4b947833868613b32e5901b764de16a90ce/blacksheep-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4c4ceda93ff84ff69bcae8386d29fff9", "sha256": "30443e2e7511c5c17277e1998e5942811fe5bedac962f771c954c26812283a49" }, "downloads": -1, "filename": "blacksheep-0.2.0.tar.gz", "has_sig": false, "md5_digest": "4c4ceda93ff84ff69bcae8386d29fff9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 624405, "upload_time": "2019-10-12T06:40:55", "url": "https://files.pythonhosted.org/packages/e5/db/b7048411409f971ab77d3e20a4b947833868613b32e5901b764de16a90ce/blacksheep-0.2.0.tar.gz" } ] }