# bareASGI
A lightweight Python [ASGI](user-guide/asgi) web server framework
(read the [docs](https://rob-blackbourn.github.io/bareASGI/)).
## Overview
This is a _bare_ ASGI web server framework. The goal is to provide
a minimal implementation, with other facilities (serving static files, CORS,
sessions, etc.) being implemented by optional packages.
The framework is targeted at micro-services which require a light footprint
(in a container for example), or as a base for larger frameworks.
Python 3.8+ is required.
## Optional Packages
- [bareASGI-cors](https://github.com/rob-blackbourn/bareASGI-cors) for cross origin resource sharing,
- [bareASGI-static](https://github.com/rob-blackbourn/bareASGI-static) for serving static files,
- [bareASGI-jinja2](https://github.com/rob-blackbourn/bareASGI-jinja2) for [Jinja2](https://github.com/pallets/jinja) template rendering,
- [bareASGI-graphql-next](https://github.com/rob-blackbourn/bareASGI-graphql-next) for [GraphQL](https://github.com/graphql-python/graphql-core) and [graphene](https://github.com/graphql-python/graphene),
- [bareASGI-rest](https://github.com/rob-blackbourn/bareASGI-rest) for REST support,
- [bareASGI-prometheus](https://github.com/rob-blackbourn/bareASGI-prometheus) for [prometheus](https://prometheus.io/) metrics,
- [bareASGI-session](https://github.com/rob-blackbourn/bareASGI-session) for sessions.
## Functionality
The framework provides the basic functionality required for developing a web
application, including:
- Http,
- WebSockets,
- Routing,
- Lifecycle,
- Middleware
## Simple Server
Here is a simple server with a request handler that returns some text.
```python
import uvicorn
from bareasgi import Application, HttpRequest, HttpResponse, text_writer
async def example_handler(request: HttpRequest) -> HttpResponse:
return HttpResponse(
200,
[(b'content-type', b'text/plain')],
text_writer('This is not a test')
)
app = Application()
app.http_router.add({'GET'}, '/', example_handler)
uvicorn.run(app, port=9009)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/rob-blackbourn/bareasgi",
"name": "bareasgi",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Rob Blackbourn",
"author_email": "rob.blackbourn@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/6e/5a/4c5135db83cfacd1a933b080c5481a5f0838ad4c2987b55c92b6c6f7653d/bareasgi-4.4.1.tar.gz",
"platform": null,
"description": "# bareASGI\n\nA lightweight Python [ASGI](user-guide/asgi) web server framework\n(read the [docs](https://rob-blackbourn.github.io/bareASGI/)).\n\n## Overview\n\nThis is a _bare_ ASGI web server framework. The goal is to provide\na minimal implementation, with other facilities (serving static files, CORS,\nsessions, etc.) being implemented by optional packages.\n\nThe framework is targeted at micro-services which require a light footprint\n(in a container for example), or as a base for larger frameworks.\n\nPython 3.8+ is required.\n\n## Optional Packages\n\n- [bareASGI-cors](https://github.com/rob-blackbourn/bareASGI-cors) for cross origin resource sharing,\n- [bareASGI-static](https://github.com/rob-blackbourn/bareASGI-static) for serving static files,\n- [bareASGI-jinja2](https://github.com/rob-blackbourn/bareASGI-jinja2) for [Jinja2](https://github.com/pallets/jinja) template rendering,\n- [bareASGI-graphql-next](https://github.com/rob-blackbourn/bareASGI-graphql-next) for [GraphQL](https://github.com/graphql-python/graphql-core) and [graphene](https://github.com/graphql-python/graphene),\n- [bareASGI-rest](https://github.com/rob-blackbourn/bareASGI-rest) for REST support,\n- [bareASGI-prometheus](https://github.com/rob-blackbourn/bareASGI-prometheus) for [prometheus](https://prometheus.io/) metrics,\n- [bareASGI-session](https://github.com/rob-blackbourn/bareASGI-session) for sessions.\n\n## Functionality\n\nThe framework provides the basic functionality required for developing a web\napplication, including:\n\n- Http,\n- WebSockets,\n- Routing,\n- Lifecycle,\n- Middleware\n\n## Simple Server\n\nHere is a simple server with a request handler that returns some text.\n\n```python\nimport uvicorn\nfrom bareasgi import Application, HttpRequest, HttpResponse, text_writer\n\nasync def example_handler(request: HttpRequest) -> HttpResponse:\n return HttpResponse(\n 200,\n [(b'content-type', b'text/plain')],\n text_writer('This is not a test')\n )\n\napp = Application()\napp.http_router.add({'GET'}, '/', example_handler)\n\nuvicorn.run(app, port=9009)\n```\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "A lightweight ASGI framework",
"version": "4.4.1",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "338db6cd6411eb1034562407c0b4b44648e8ca35971f34fe82a81a1a04f5acb3",
"md5": "4e3492a262b69532b3d9afbd3dc4e3ef",
"sha256": "82823b0e452d80981682fbe637feef604910b0b68eaec83224e20ae248e39ad8"
},
"downloads": -1,
"filename": "bareasgi-4.4.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4e3492a262b69532b3d9afbd3dc4e3ef",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 30930,
"upload_time": "2023-04-28T08:46:40",
"upload_time_iso_8601": "2023-04-28T08:46:40.938384Z",
"url": "https://files.pythonhosted.org/packages/33/8d/b6cd6411eb1034562407c0b4b44648e8ca35971f34fe82a81a1a04f5acb3/bareasgi-4.4.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6e5a4c5135db83cfacd1a933b080c5481a5f0838ad4c2987b55c92b6c6f7653d",
"md5": "c000c553430f05d40694587ecd734a61",
"sha256": "07743cf8e880b4fca9e3fb582c92ee0a5360d4280b091d5bc0bd00f0b4090e59"
},
"downloads": -1,
"filename": "bareasgi-4.4.1.tar.gz",
"has_sig": false,
"md5_digest": "c000c553430f05d40694587ecd734a61",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 22349,
"upload_time": "2023-04-28T08:46:43",
"upload_time_iso_8601": "2023-04-28T08:46:43.599930Z",
"url": "https://files.pythonhosted.org/packages/6e/5a/4c5135db83cfacd1a933b080c5481a5f0838ad4c2987b55c92b6c6f7653d/bareasgi-4.4.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-28 08:46:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "rob-blackbourn",
"github_project": "bareasgi",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "bareasgi"
}