fastapi-extras3


Namefastapi-extras3 JSON
Version 0.3.0 PyPI version JSON
download
home_pageNone
SummaryUtilities to make using fastapi a little easier.
upload_time2024-11-25 22:07:21
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseThe MIT License (MIT) Copyright (c) 2024 Andrew C Scott Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords fastapi utils session sync dataclass
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            fastapi-extras
---------------

A series of extras and utilities that make using
[fastapi](https://github.com/tiangolo/fastapi) a little bit easier

### Features

- Modular and Configurable Session Management
- Synchronous Request Getter Utilities using Depends
- Helpers for using [pyderive dataclasses](https://github.com/imgurbot12/pyderive)

### Examples

Session Middleware

```python3
from fastapi import FastAPI
from fastapi_extras.session import SessionMiddleware

# drop in replacement for starlette SessionMiddleware
app = FastAPI()
app.add_middleware(SessionMiddleware)

# customizable and configurable storage interface
from fastapi_extras.session.fs import FileStore

app = FastAPI()
app.add_middleware(SessionMiddleware, store=FileStore())
```

Synchronous Getters

```python3
from fastapi import FastAPI, Request
from fastapi_extras.getters import form

app = FastAPI()

@app.post('/async')
async def async_form(request: Request):
    """collect form object using async function call"""
    form = await request.form()
    return form

@app.post('/sync')
def sync_form(request: Request, form = form()):
    """collect async form resource without async using dependency"""
    return form
```

Pyderive Helpers

```python3
from fastapi import FastAPI, Request
from fastapi_extras.session import SessionMiddleware
from fastapi_extras.getters import as_session
from pyderive.extensions.validate import BaseModel, IPv4

class Session(BaseModel):
    ip: IPv4

app = FastAPI()
app.add_middleware(SessionMiddleware)

@app.get('/start')
def start(request: Request) -> str:
    host = request.client.host if request.client else '127.0.0.1'
    request.session['ip'] = host
    return 'Session Started'

@app.get('/check')
def check(session: Session = as_session(Session)):
    return f'Your IPAddress is {session.ip!r}'
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "fastapi-extras3",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "fastapi, utils, session, sync, dataclass",
    "author": null,
    "author_email": "Andrew Scott <imgurbot12@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/45/88/1d9d1cd0e3230c2ba8cb4f51be7f07675a1ba6868d07ddcb41e3b7b8b36d/fastapi_extras3-0.3.0.tar.gz",
    "platform": null,
    "description": "fastapi-extras\n---------------\n\nA series of extras and utilities that make using\n[fastapi](https://github.com/tiangolo/fastapi) a little bit easier\n\n### Features\n\n- Modular and Configurable Session Management\n- Synchronous Request Getter Utilities using Depends\n- Helpers for using [pyderive dataclasses](https://github.com/imgurbot12/pyderive)\n\n### Examples\n\nSession Middleware\n\n```python3\nfrom fastapi import FastAPI\nfrom fastapi_extras.session import SessionMiddleware\n\n# drop in replacement for starlette SessionMiddleware\napp = FastAPI()\napp.add_middleware(SessionMiddleware)\n\n# customizable and configurable storage interface\nfrom fastapi_extras.session.fs import FileStore\n\napp = FastAPI()\napp.add_middleware(SessionMiddleware, store=FileStore())\n```\n\nSynchronous Getters\n\n```python3\nfrom fastapi import FastAPI, Request\nfrom fastapi_extras.getters import form\n\napp = FastAPI()\n\n@app.post('/async')\nasync def async_form(request: Request):\n    \"\"\"collect form object using async function call\"\"\"\n    form = await request.form()\n    return form\n\n@app.post('/sync')\ndef sync_form(request: Request, form = form()):\n    \"\"\"collect async form resource without async using dependency\"\"\"\n    return form\n```\n\nPyderive Helpers\n\n```python3\nfrom fastapi import FastAPI, Request\nfrom fastapi_extras.session import SessionMiddleware\nfrom fastapi_extras.getters import as_session\nfrom pyderive.extensions.validate import BaseModel, IPv4\n\nclass Session(BaseModel):\n    ip: IPv4\n\napp = FastAPI()\napp.add_middleware(SessionMiddleware)\n\n@app.get('/start')\ndef start(request: Request) -> str:\n    host = request.client.host if request.client else '127.0.0.1'\n    request.session['ip'] = host\n    return 'Session Started'\n\n@app.get('/check')\ndef check(session: Session = as_session(Session)):\n    return f'Your IPAddress is {session.ip!r}'\n```\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)  Copyright (c) 2024 Andrew C Scott  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  ",
    "summary": "Utilities to make using fastapi a little easier.",
    "version": "0.3.0",
    "project_urls": {
        "homepage": "https://github.com/imgurbot12/fastapi-extras"
    },
    "split_keywords": [
        "fastapi",
        " utils",
        " session",
        " sync",
        " dataclass"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e0d6492ddcbfec94aaab98ba749f0ee5c5291b997f61e32e14ae417de48040c6",
                "md5": "f9679ad7712e193f9810cfc3a0aaad67",
                "sha256": "5d3cf860ea1dc7ceebf01650c460f2937845cf799dd13495b072cb3178f12003"
            },
            "downloads": -1,
            "filename": "fastapi_extras3-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f9679ad7712e193f9810cfc3a0aaad67",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11042,
            "upload_time": "2024-11-25T22:07:19",
            "upload_time_iso_8601": "2024-11-25T22:07:19.534588Z",
            "url": "https://files.pythonhosted.org/packages/e0/d6/492ddcbfec94aaab98ba749f0ee5c5291b997f61e32e14ae417de48040c6/fastapi_extras3-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "45881d9d1cd0e3230c2ba8cb4f51be7f07675a1ba6868d07ddcb41e3b7b8b36d",
                "md5": "1caf9478c3aec1b8b610b53ad0c4b1fa",
                "sha256": "d02263f1f32b4ac8ce65e6fadcd7a9a043c2a11b23b729b61b621d67218c1de9"
            },
            "downloads": -1,
            "filename": "fastapi_extras3-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1caf9478c3aec1b8b610b53ad0c4b1fa",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 10233,
            "upload_time": "2024-11-25T22:07:21",
            "upload_time_iso_8601": "2024-11-25T22:07:21.269344Z",
            "url": "https://files.pythonhosted.org/packages/45/88/1d9d1cd0e3230c2ba8cb4f51be7f07675a1ba6868d07ddcb41e3b7b8b36d/fastapi_extras3-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-25 22:07:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "imgurbot12",
    "github_project": "fastapi-extras",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "fastapi-extras3"
}
        
Elapsed time: 0.37643s