https://github.com/neothebestdeveloper/neopoint
WSGI python backend framework
https://github.com/neothebestdeveloper/neopoint
Last synced: about 1 year ago
JSON representation
WSGI python backend framework
- Host: GitHub
- URL: https://github.com/neothebestdeveloper/neopoint
- Owner: NeoTheBestDeveloper
- License: mit
- Created: 2023-07-14T06:03:43.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-08-10T11:31:55.000Z (almost 2 years ago)
- Last Synced: 2024-08-10T12:26:37.539Z (almost 2 years ago)
- Language: Python
- Homepage:
- Size: 201 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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