Name | neopoint JSON |
Version |
0.0.1
JSON |
| download |
home_page | None |
Summary | Just a web framework for myself learning how they work. |
upload_time | 2024-04-28 16:18:08 |
maintainer | None |
docs_url | None |
author | NeoTheBestDeveloper |
requires_python | <=3.12,>=3.10 |
license | MIT |
keywords |
web
framework
http
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Neopoint
## Warning - project is unstable.
Neopoint is a simple backend framework, which support routing, parsing query and path parametrs etc.
## Examples
### Create base app
```python
from neopoint import App
from neopoint.routing import Router
router = Router(prefix="/api")
app = App(debug=True)
app.include_router(router)
```
### Let's add some endpoints
```py
from neopoint.http import JsonResponse
@router.get("/users/{user_id}")
def get_user_by_id(user_id: int) -> JsonResponse:
return JsonResponse(
{
"id": user_id,
"first_name": "John",
"last_name": "Doe",
}
)
```
You can add pattern at endpoint path like {NAME_OF_PARAMETR} and it will be passed to your controller function.
### Let's parse also query parametrs.
```py
from neopoint.http import JsonResponse
@router.get("/users")
def get_users(limit: int = 15, sort: str = "ASC") -> JsonResponse:
return JsonResponse(
{
"id": user_id,
"limit": limit,
"sort": sort,
}
)
```
### How to handle post and other requests with payload?
```python
@router.post("/theme")
def create_theme(req: Request) -> JsonResponse:
return JsonResponse(req.json)
```
For handling requests you can pass request parametr to your controller.
Request attributes:
- headers -> MappingProxyType\[str, str]
- query_params -> QueryParams
- path_params -> PathParams
- method -> RequestMethod
- path -> str
- json -> Any
- content -> bytes
Raw data
{
"_id": null,
"home_page": null,
"name": "neopoint",
"maintainer": null,
"docs_url": null,
"requires_python": "<=3.12,>=3.10",
"maintainer_email": null,
"keywords": "web, framework, HTTP",
"author": "NeoTheBestDeveloper",
"author_email": "neothebestmain@protonmail.com",
"download_url": "https://files.pythonhosted.org/packages/cd/5f/8d91ac125f85d83cf1aef17065e13563ebb479a236faf38dee37a4907243/neopoint-0.0.1.tar.gz",
"platform": null,
"description": "# Neopoint\n\n## Warning - project is unstable.\n\nNeopoint is a simple backend framework, which support routing, parsing query and path parametrs etc.\n\n## Examples\n\n### Create base app\n\n```python\nfrom neopoint import App\nfrom neopoint.routing import Router\n\n\nrouter = Router(prefix=\"/api\")\n\napp = App(debug=True)\napp.include_router(router)\n```\n\n### Let's add some endpoints\n```py \nfrom neopoint.http import JsonResponse\n\n@router.get(\"/users/{user_id}\")\ndef get_user_by_id(user_id: int) -> JsonResponse:\n return JsonResponse(\n {\n \"id\": user_id,\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n }\n )\n```\n\n\nYou can add pattern at endpoint path like {NAME_OF_PARAMETR} and it will be passed to your controller function.\n\n### Let's parse also query parametrs.\n\n```py \nfrom neopoint.http import JsonResponse\n\n@router.get(\"/users\")\ndef get_users(limit: int = 15, sort: str = \"ASC\") -> JsonResponse:\n return JsonResponse(\n {\n \"id\": user_id,\n \"limit\": limit,\n \"sort\": sort,\n }\n )\n```\n\n### How to handle post and other requests with payload?\n\n```python\n@router.post(\"/theme\")\ndef create_theme(req: Request) -> JsonResponse:\n return JsonResponse(req.json)\n```\n\nFor handling requests you can pass request parametr to your controller.\n\nRequest attributes:\n- headers -> MappingProxyType\\[str, str]\n- query_params -> QueryParams\n- path_params -> PathParams\n- method -> RequestMethod\n- path -> str\n- json -> Any\n- content -> bytes\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Just a web framework for myself learning how they work.",
"version": "0.0.1",
"project_urls": null,
"split_keywords": [
"web",
" framework",
" http"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "975e12190b3de068de4b09d4459f22ab84ee5c018b60ecb2d2bb2a3259ea8166",
"md5": "35c687289b4b021dfd5bacec2442db5e",
"sha256": "7304f6a1f013a6b8a4cff32771179f4e588aaf5774f9d5b49f0d6e1a0d358bfe"
},
"downloads": -1,
"filename": "neopoint-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "35c687289b4b021dfd5bacec2442db5e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<=3.12,>=3.10",
"size": 19848,
"upload_time": "2024-04-28T16:18:06",
"upload_time_iso_8601": "2024-04-28T16:18:06.840215Z",
"url": "https://files.pythonhosted.org/packages/97/5e/12190b3de068de4b09d4459f22ab84ee5c018b60ecb2d2bb2a3259ea8166/neopoint-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cd5f8d91ac125f85d83cf1aef17065e13563ebb479a236faf38dee37a4907243",
"md5": "47892821efe3e77520519fdf040a3e24",
"sha256": "935305fb0106b5fa243d7a1bbc398f20166668f662d48d4a312dfc632f945279"
},
"downloads": -1,
"filename": "neopoint-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "47892821efe3e77520519fdf040a3e24",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<=3.12,>=3.10",
"size": 13633,
"upload_time": "2024-04-28T16:18:08",
"upload_time_iso_8601": "2024-04-28T16:18:08.922760Z",
"url": "https://files.pythonhosted.org/packages/cd/5f/8d91ac125f85d83cf1aef17065e13563ebb479a236faf38dee37a4907243/neopoint-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-28 16:18:08",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "neopoint"
}