Python
# myapp/ajax.py
from adjax.registry import registry
from adjax.utils.types import typed
MESSAGE = 'Hello {who} and welcome to {where}'
@registry.register
@typed(strict=True)
def visit(request, where: str, who: str) -> dict:
"""Visit the specified lands."""
return {
'who': who,
'where': where,
'message': MESSAGE.format(who=who, where=where),
}
Browser (JavaScript)
// static/example.js
ADJAX.apps.myapp.visit('Vinland', 'Leif', function (data) {
data == {
who: "Leif",
where: "Vinland",
message: "Hello Leif and welcome to Vinland"
}
});
ADJAX.apps.myapp.visit(33, 42, function (data) {
data == {
error: true,
message: "Value 42 of type class (...)"
}
});