uHTTP-Session


NameuHTTP-Session JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/0x67757300/uHTTP-Session
SummarySession support for µHTTP
upload_time2023-12-14 23:46:06
maintainer
docs_urlNone
authorgus
requires_python>=3.9,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # µHTTP Session

Session support for µHTTP

Sessions are implemented as [Javascript Web Signatures](https://datatracker.ietf.org/doc/html/rfc7515). Which means that:

1. Sessions are stored in the client's browser.
2. Sessions are not secret.
3. Sessions cannot be tempered with.

### Installation

µHTTP Session is on [PyPI](https://pypi.org/project/uhttp-session/).

```bash
pip install uhttp-session
```

### Usage

First, you must set the secret key as an environment variable:

```bash
export APP_SECRET='<your secret key goes here>'
```

Don't have one?

```bash
python -c 'import secrets; print(secrets.token_hex())'
```

Then:

```python
from uhttp import App
from uhttp_session import app as session_app

app = App()
app.mount(session_app)

@app.post('/login')
def login(request):
    request.state['session']['user'] = request.form.get('user', 'john')


@app.get('/'):
def account(request):
    if 'user' not in request.state['session']:
        return 401
    else:
        return f'Hello, {request.state["session"]["user"]}!'
```

### License

Released under the MIT license.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/0x67757300/uHTTP-Session",
    "name": "uHTTP-Session",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "gus",
    "author_email": "0x67757300@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/7c/0b/09e7ee5408dbe5353b026c9837ccda3bbcaa4813e41a2644bf0d507c81d1/uhttp_session-0.1.2.tar.gz",
    "platform": null,
    "description": "# \u00b5HTTP Session\n\nSession support for \u00b5HTTP\n\nSessions are implemented as [Javascript Web Signatures](https://datatracker.ietf.org/doc/html/rfc7515). Which means that:\n\n1. Sessions are stored in the client's browser.\n2. Sessions are not secret.\n3. Sessions cannot be tempered with.\n\n### Installation\n\n\u00b5HTTP Session is on [PyPI](https://pypi.org/project/uhttp-session/).\n\n```bash\npip install uhttp-session\n```\n\n### Usage\n\nFirst, you must set the secret key as an environment variable:\n\n```bash\nexport APP_SECRET='<your secret key goes here>'\n```\n\nDon't have one?\n\n```bash\npython -c 'import secrets; print(secrets.token_hex())'\n```\n\nThen:\n\n```python\nfrom uhttp import App\nfrom uhttp_session import app as session_app\n\napp = App()\napp.mount(session_app)\n\n@app.post('/login')\ndef login(request):\n    request.state['session']['user'] = request.form.get('user', 'john')\n\n\n@app.get('/'):\ndef account(request):\n    if 'user' not in request.state['session']:\n        return 401\n    else:\n        return f'Hello, {request.state[\"session\"][\"user\"]}!'\n```\n\n### License\n\nReleased under the MIT license.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Session support for \u00b5HTTP",
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://github.com/0x67757300/uHTTP-Session",
        "Repository": "https://github.com/0x67757300/uHTTP-Session"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "84707a3eab51ccaa6cd17fb4f3381c12b84d43a167c017521827607f1e965eef",
                "md5": "591f95573f99d794c4ed238408d6b800",
                "sha256": "3de052c2b0901b727e32667356d43fdc363d388426bc22c01017f63e171821d8"
            },
            "downloads": -1,
            "filename": "uhttp_session-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "591f95573f99d794c4ed238408d6b800",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 3065,
            "upload_time": "2023-12-14T23:46:04",
            "upload_time_iso_8601": "2023-12-14T23:46:04.798917Z",
            "url": "https://files.pythonhosted.org/packages/84/70/7a3eab51ccaa6cd17fb4f3381c12b84d43a167c017521827607f1e965eef/uhttp_session-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7c0b09e7ee5408dbe5353b026c9837ccda3bbcaa4813e41a2644bf0d507c81d1",
                "md5": "9894bc5e337caa4f11d9b352622bc8be",
                "sha256": "cf4cb23afaa70082ae8f66b2ea470404aa98d8cb304e87944159b52c5d964d63"
            },
            "downloads": -1,
            "filename": "uhttp_session-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "9894bc5e337caa4f11d9b352622bc8be",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 2528,
            "upload_time": "2023-12-14T23:46:06",
            "upload_time_iso_8601": "2023-12-14T23:46:06.481548Z",
            "url": "https://files.pythonhosted.org/packages/7c/0b/09e7ee5408dbe5353b026c9837ccda3bbcaa4813e41a2644bf0d507c81d1/uhttp_session-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-14 23:46:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "0x67757300",
    "github_project": "uHTTP-Session",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "uhttp-session"
}
        
gus
Elapsed time: 0.15030s