Just a web framework for myself learning how they work.
Project description
Neopoint
Warning - project is unstable.
Neopoint is a simple backend framework, which support routing, parsing query and path parametrs etc.
Examples
Create base app
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
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.
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?
@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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
neopoint-0.0.1.tar.gz
(13.6 kB
view details)
Built Distribution
neopoint-0.0.1-py3-none-any.whl
(19.8 kB
view details)
File details
Details for the file neopoint-0.0.1.tar.gz
.
File metadata
- Download URL: neopoint-0.0.1.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.8 Linux/6.8.1-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 935305fb0106b5fa243d7a1bbc398f20166668f662d48d4a312dfc632f945279 |
|
MD5 | 47892821efe3e77520519fdf040a3e24 |
|
BLAKE2b-256 | cd5f8d91ac125f85d83cf1aef17065e13563ebb479a236faf38dee37a4907243 |
File details
Details for the file neopoint-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: neopoint-0.0.1-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.8 Linux/6.8.1-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7304f6a1f013a6b8a4cff32771179f4e588aaf5774f9d5b49f0d6e1a0d358bfe |
|
MD5 | 35c687289b4b021dfd5bacec2442db5e |
|
BLAKE2b-256 | 975e12190b3de068de4b09d4459f22ab84ee5c018b60ecb2d2bb2a3259ea8166 |