Skip to main content

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


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 hashes)

Uploaded Source

Built Distribution

neopoint-0.0.1-py3-none-any.whl (19.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page