naja-atra-asgi


Namenaja-atra-asgi JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryThis is a simple http server, use MVC like design.
upload_time2024-04-11 12:23:02
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT License Copyright (c) 2018 Keijack Wu 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 http-server websocket http web web-server
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Naja Atra ASGI

This ia a ASGI proxy that proxies requests to Naja Atra.

# Usage

Take `uvicorn` as an example.

```python
import uvicorn
There is a legacy application
from naja_atra import route
from naja_atra_asgi import app

@route("/hello")
def hello(name: str):
    return {"messag": f"Hello, {name}!"}

if __name__ == '__main__':
    uvicon_conf = uvicorn.Config(
        app, host="0.0.0.0", port=9090, log_level="info")
    asgi_server = uvicorn.Server(uvicon_conf)
    asgi_server.run()
```

You can use `server.scan()` to import routes from other modules. And also you can use `naja_atra_asgi.config()` to function to sepecify the static resources routes.

```python
import os
import uvicorn
import naja_atra.server as server

from naja_atra import route
from naja_atra_asgi import config, app

PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))

if __name__ == '__main__':
    server.scan(base_dir="tests/ctrls", regx=r'.*controllers.*',
                project_dir=PROJECT_ROOT)
    config(
        resources={"/public/*": f"{PROJECT_ROOT}/tests/static",
                   "/*": f"{PROJECT_ROOT}/tests/static"})
    uvicon_conf = uvicorn.Config(
        app, host="0.0.0.0", port=9090, log_level="info")
    asgi_server = uvicorn.Server(uvicon_conf)
    asgi_server.run()
```

## Legacy Applications

You can use the legacy ASGI (V2) application function `app_v2` if your server does not support ASGI V3.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "naja-atra-asgi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "http-server, websocket, http, web, web-server",
    "author": null,
    "author_email": "keijack <keijack.wu@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/db/5d/3b935a4f290d61474bfe1f18282f88a80ad2392cf8188d499368a7b3f22f/naja-atra-asgi-1.0.1.tar.gz",
    "platform": null,
    "description": "# Naja Atra ASGI\n\nThis ia a ASGI proxy that proxies requests to Naja Atra.\n\n# Usage\n\nTake `uvicorn` as an example.\n\n```python\nimport uvicorn\nThere is a legacy application\nfrom naja_atra import route\nfrom naja_atra_asgi import app\n\n@route(\"/hello\")\ndef hello(name: str):\n    return {\"messag\": f\"Hello, {name}!\"}\n\nif __name__ == '__main__':\n    uvicon_conf = uvicorn.Config(\n        app, host=\"0.0.0.0\", port=9090, log_level=\"info\")\n    asgi_server = uvicorn.Server(uvicon_conf)\n    asgi_server.run()\n```\n\nYou can use `server.scan()` to import routes from other modules. And also you can use `naja_atra_asgi.config()` to function to sepecify the static resources routes.\n\n```python\nimport os\nimport uvicorn\nimport naja_atra.server as server\n\nfrom naja_atra import route\nfrom naja_atra_asgi import config, app\n\nPROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))\n\nif __name__ == '__main__':\n    server.scan(base_dir=\"tests/ctrls\", regx=r'.*controllers.*',\n                project_dir=PROJECT_ROOT)\n    config(\n        resources={\"/public/*\": f\"{PROJECT_ROOT}/tests/static\",\n                   \"/*\": f\"{PROJECT_ROOT}/tests/static\"})\n    uvicon_conf = uvicorn.Config(\n        app, host=\"0.0.0.0\", port=9090, log_level=\"info\")\n    asgi_server = uvicorn.Server(uvicon_conf)\n    asgi_server.run()\n```\n\n## Legacy Applications\n\nYou can use the legacy ASGI (V2) application function `app_v2` if your server does not support ASGI V3.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2018 Keijack Wu  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": "This is a simple http server, use MVC like design.",
    "version": "1.0.1",
    "project_urls": {
        "homepage": "https://github.com/naja-atra/naja-atra-asgi",
        "repository": "https://github.com/naja-atra/naja-atra-asgi"
    },
    "split_keywords": [
        "http-server",
        " websocket",
        " http",
        " web",
        " web-server"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d0178d9b6ea05602acb2240c5e5bcb32aaa26441643ae58d38ae74d78b7d272d",
                "md5": "c69a62d209819ef167cc0eb0932f949b",
                "sha256": "0ad449fea2669d017f5a2c4e31f5da96e683ca43cb516258b46847e5b46c1122"
            },
            "downloads": -1,
            "filename": "naja_atra_asgi-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c69a62d209819ef167cc0eb0932f949b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 8686,
            "upload_time": "2024-04-11T12:23:00",
            "upload_time_iso_8601": "2024-04-11T12:23:00.303548Z",
            "url": "https://files.pythonhosted.org/packages/d0/17/8d9b6ea05602acb2240c5e5bcb32aaa26441643ae58d38ae74d78b7d272d/naja_atra_asgi-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "db5d3b935a4f290d61474bfe1f18282f88a80ad2392cf8188d499368a7b3f22f",
                "md5": "bc6352a64b0732f8eea2348d342ca941",
                "sha256": "9fc11343d020cfe01f4a3caa205c108af6db429bfb725e73dd520dd770140c64"
            },
            "downloads": -1,
            "filename": "naja-atra-asgi-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "bc6352a64b0732f8eea2348d342ca941",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 7170,
            "upload_time": "2024-04-11T12:23:02",
            "upload_time_iso_8601": "2024-04-11T12:23:02.055483Z",
            "url": "https://files.pythonhosted.org/packages/db/5d/3b935a4f290d61474bfe1f18282f88a80ad2392cf8188d499368a7b3f22f/naja-atra-asgi-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-11 12:23:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "naja-atra",
    "github_project": "naja-atra-asgi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "naja-atra-asgi"
}
        
Elapsed time: 0.27106s