API and token example

A compact example based on the API and token calls shown in the project’s current documentation.

from EasyModel import ApiEngine, TokenManager

tokens = TokenManager()
api = ApiEngine()

def hello(data, headers):
    return {"hello": "world"}

api.get("/", hello)
api.start()

token = tokens.issue("user1")
print(tokens.verify(token))

Before you adapt it

This page documents the example shape, not production authentication. Review how the package validates tokens and handles routes before using either feature for access control.

PreviousNext