dyne


Namedyne JSON
Version 1.0.7 PyPI version JSON
download
home_pageNone
SummaryA light weight Python async framework with batteries included.
upload_time2024-10-21 22:46:27
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## A light weight Python async framework with batteries included

[![Build](https://github.com/tabotkevin/dyne/actions/workflows/build.yaml/badge.svg)](https://github.com/tabotkevin/dyne/actions/workflows/build.yaml)
[![Documentation Status](https://readthedocs.org/projects/dyneapi/badge/?version=latest)](https://dyneapi.readthedocs.io/en/latest/?badge=latest)
[![image](https://img.shields.io/pypi/v/dyne.svg)](https://pypi.org/project/dyne/)
[![image](https://img.shields.io/pypi/l/dyne.svg)](https://pypi.org/project/dyne/)
[![image](https://img.shields.io/pypi/pyversions/dyne.svg)](https://pypi.org/project/dyne/)
[![image](https://img.shields.io/github/contributors/tabotkevin/dyne.svg)](https://github.com/tabotkevin/dyne/graphs/contributors)

```python
import dyne

api = dyne.API()

@api.route("/create", methods=["POST"])
@api.authenticate(basic_auth, role="user")
@api.input(BookCreateSchema, location="form")
@api.output(BookSchema)
@api.expect(
    {
        401: "Invalid credentials",
    }
)
async def create(req, resp, *, data):
    """Create book"""

    image = data.pop("image")
    await image.save(image.filename)  # File already validated for extension and size.

    book = Book(**data, cover=image.filename)
    session.add(book)
    session.commit()

    resp.obj = book

if __name__ == "__main__":
  api.run()
```

Powered by [Starlette](https://www.starlette.io/). [View documentation](https://dyneapi.readthedocs.io).

This gets you a ASGI app, with a production static files server pre-installed, jinja2
templating (without additional imports), and a production webserver based on uvloop,
serving up requests with gzip compression automatically.

## More Examples

See
[the documentation's feature tour](https://dyneapi.readthedocs.io/en/latest/tour.html)
for more details on features available in dyne.

## Installing dyne

Install the stable release:

    pip install dyne

## The Basic Idea

The primary concept here is to bring the niceties that are brought forth from both Flask
and Falcon and unify them into a single framework, along with some new ideas I have. I
also wanted to take some of the API primitives that are instilled in the Requests
library and put them into a web framework. So, you'll find a lot of parallels here with
Requests.

- Setting `resp.content` sends back bytes.
- Setting `resp.text` sends back unicode, while setting `resp.html` sends back HTML.
- Setting `resp.media` sends back JSON/YAML (`.text`/`.html`/`.content` override this).
- Setting `resp.obj` deserializes SQLAlchemy object(s) using Pydantic or Marshmallow schemas
- Case-insensitive `req.headers` dict (from Requests directly).
- `resp.status_code`, `req.method`, `req.url`, and other familiar friends.

## Ideas

- Flask-style route expression, with new capabilities -- all while using Python 3.6+'s
  new f-string syntax.
- I love Falcon's "every request and response is passed into to each view and mutated"
  methodology, especially `response.media`, and have used it here. In addition to
  supporting JSON, I have decided to support YAML as well, as Kubernetes is slowly
  taking over the world, and it uses YAML for all the things. Content-negotiation and
  all that.
- **A built in testing client that uses the actual Requests you know and love**.
- The ability to mount other WSGI apps easily.
- Automatic gzipped-responses.
- In addition to Falcon's `on_get`, `on_post`, etc methods, dyne features an
  `on_request` method, which gets called on every type of request, much like Requests.
- A production static file server is built-in.
- Uvicorn built-in as a production web server. I would have chosen Gunicorn, but it
  doesn't run on Windows. Plus, Uvicorn serves well to protect against slowloris
  attacks, making nginx unnecessary in production.
- GraphQL support, via Graphene. The goal here is to have any GraphQL query exposable at
  any route, magically.
- Provide an official way to run webpack.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dyne",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Tabot Kevin <tabot.kevin@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/04/07/96d7edbbc4bd70ca7ccf3bdeb812e2faa648924de317ad3057806b3d23ec/dyne-1.0.7.tar.gz",
    "platform": null,
    "description": "## A light weight Python async framework with batteries included\n\n[![Build](https://github.com/tabotkevin/dyne/actions/workflows/build.yaml/badge.svg)](https://github.com/tabotkevin/dyne/actions/workflows/build.yaml)\n[![Documentation Status](https://readthedocs.org/projects/dyneapi/badge/?version=latest)](https://dyneapi.readthedocs.io/en/latest/?badge=latest)\n[![image](https://img.shields.io/pypi/v/dyne.svg)](https://pypi.org/project/dyne/)\n[![image](https://img.shields.io/pypi/l/dyne.svg)](https://pypi.org/project/dyne/)\n[![image](https://img.shields.io/pypi/pyversions/dyne.svg)](https://pypi.org/project/dyne/)\n[![image](https://img.shields.io/github/contributors/tabotkevin/dyne.svg)](https://github.com/tabotkevin/dyne/graphs/contributors)\n\n```python\nimport dyne\n\napi = dyne.API()\n\n@api.route(\"/create\", methods=[\"POST\"])\n@api.authenticate(basic_auth, role=\"user\")\n@api.input(BookCreateSchema, location=\"form\")\n@api.output(BookSchema)\n@api.expect(\n    {\n        401: \"Invalid credentials\",\n    }\n)\nasync def create(req, resp, *, data):\n    \"\"\"Create book\"\"\"\n\n    image = data.pop(\"image\")\n    await image.save(image.filename)  # File already validated for extension and size.\n\n    book = Book(**data, cover=image.filename)\n    session.add(book)\n    session.commit()\n\n    resp.obj = book\n\nif __name__ == \"__main__\":\n  api.run()\n```\n\nPowered by [Starlette](https://www.starlette.io/). [View documentation](https://dyneapi.readthedocs.io).\n\nThis gets you a ASGI app, with a production static files server pre-installed, jinja2\ntemplating (without additional imports), and a production webserver based on uvloop,\nserving up requests with gzip compression automatically.\n\n## More Examples\n\nSee\n[the documentation's feature tour](https://dyneapi.readthedocs.io/en/latest/tour.html)\nfor more details on features available in dyne.\n\n## Installing dyne\n\nInstall the stable release:\n\n    pip install dyne\n\n## The Basic Idea\n\nThe primary concept here is to bring the niceties that are brought forth from both Flask\nand Falcon and unify them into a single framework, along with some new ideas I have. I\nalso wanted to take some of the API primitives that are instilled in the Requests\nlibrary and put them into a web framework. So, you'll find a lot of parallels here with\nRequests.\n\n- Setting `resp.content` sends back bytes.\n- Setting `resp.text` sends back unicode, while setting `resp.html` sends back HTML.\n- Setting `resp.media` sends back JSON/YAML (`.text`/`.html`/`.content` override this).\n- Setting `resp.obj` deserializes SQLAlchemy object(s) using Pydantic or Marshmallow schemas\n- Case-insensitive `req.headers` dict (from Requests directly).\n- `resp.status_code`, `req.method`, `req.url`, and other familiar friends.\n\n## Ideas\n\n- Flask-style route expression, with new capabilities -- all while using Python 3.6+'s\n  new f-string syntax.\n- I love Falcon's \"every request and response is passed into to each view and mutated\"\n  methodology, especially `response.media`, and have used it here. In addition to\n  supporting JSON, I have decided to support YAML as well, as Kubernetes is slowly\n  taking over the world, and it uses YAML for all the things. Content-negotiation and\n  all that.\n- **A built in testing client that uses the actual Requests you know and love**.\n- The ability to mount other WSGI apps easily.\n- Automatic gzipped-responses.\n- In addition to Falcon's `on_get`, `on_post`, etc methods, dyne features an\n  `on_request` method, which gets called on every type of request, much like Requests.\n- A production static file server is built-in.\n- Uvicorn built-in as a production web server. I would have chosen Gunicorn, but it\n  doesn't run on Windows. Plus, Uvicorn serves well to protect against slowloris\n  attacks, making nginx unnecessary in production.\n- GraphQL support, via Graphene. The goal here is to have any GraphQL query exposable at\n  any route, magically.\n- Provide an official way to run webpack.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A light weight Python async framework with batteries included.",
    "version": "1.0.7",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3e8c1de7081f8a99311cb1972d18fa0af82ffc2266ef45445451df02f41c2b37",
                "md5": "bb22b1a37d6e91fcb8b3342ea545bf7b",
                "sha256": "cb83978ffab34ce2b16c43271c21d7a515bff748a2b16be285dffcd7fcaad380"
            },
            "downloads": -1,
            "filename": "dyne-1.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bb22b1a37d6e91fcb8b3342ea545bf7b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 38587,
            "upload_time": "2024-10-21T22:46:17",
            "upload_time_iso_8601": "2024-10-21T22:46:17.103354Z",
            "url": "https://files.pythonhosted.org/packages/3e/8c/1de7081f8a99311cb1972d18fa0af82ffc2266ef45445451df02f41c2b37/dyne-1.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "040796d7edbbc4bd70ca7ccf3bdeb812e2faa648924de317ad3057806b3d23ec",
                "md5": "2143a0e6fc58901dbb93ff36107f6a15",
                "sha256": "6060385b4ddb56db44b32c61e82acb973bcfb1f9e10d216acb0b126989c13a77"
            },
            "downloads": -1,
            "filename": "dyne-1.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "2143a0e6fc58901dbb93ff36107f6a15",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8877262,
            "upload_time": "2024-10-21T22:46:27",
            "upload_time_iso_8601": "2024-10-21T22:46:27.419655Z",
            "url": "https://files.pythonhosted.org/packages/04/07/96d7edbbc4bd70ca7ccf3bdeb812e2faa648924de317ad3057806b3d23ec/dyne-1.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-21 22:46:27",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "dyne"
}
        
Elapsed time: 0.58142s