Flaxon 0.3.0 and Teloce-Py 0.3.0 are available on PyPI. Release instructions are maintained on this site; source links identify the framework snapshot. Check version and upgrade guidance.
Application API
For generated projects, use the shared settings.py, Flaxon.from_settings(),
explicit mounts in app.py, and management.py workflow. See ORM and project management
for Python migrations, model registration, permission hooks, relationship editing,
and Admin/CMS metadata storage. Backend-only and legacy adapter examples remain supported.
Flaxon
The main application class.
Constructor
Flaxon(
name: str,
*,
debug: bool | None = None,
config: dict[str, Any] | None = None,
openapi: bool | dict[str, Any] = False
)
Parameters
| Parameter | Type | Description |
|---|---|---|
name |
str |
Application name |
debug |
bool \| None |
Enable debug mode |
config |
dict[str, Any] \| None |
Configuration dictionary |
openapi |
bool \| dict[str, Any] |
Enable automatic OpenAPI, Swagger UI, and ReDoc. A mapping supplies enable_openapi() options. |
Routing Methods
route
route(
path: str,
*,
methods: set[str] | list[str] | tuple[str, ...] = ("GET",),
name: str | None = None,
summary: str | None = None,
description: str | None = None,
tags: list[str] | None = None,
operation_id: str | None = None,
responses: dict[str | int, Any] | None = None,
deprecated: bool = False,
security: list[dict[str, list[str]]] | None = None
) -> Callable
Register a route with custom HTTP methods.
The get, post, put, patch, and delete helpers accept the same
OpenAPI metadata: summary, description, tags, operation_id,
responses, deprecated, and security.
See the OpenAPI guide for query parameters, schemas, guards, and CLI validation.
get
get(
path: str,
*,
name: str | None = None
) -> Callable
Register a GET route.
post
post(
path: str,
*,
name: str | None = None
) -> Callable
Register a POST route.
put
put(
path: str,
*,
name: str | None = None
) -> Callable
Register a PUT route.
patch
patch(
path: str,
*,
name: str | None = None
) -> Callable
Register a PATCH route.
delete
delete(
path: str,
*,
name: str | None = None
) -> Callable
Register a DELETE route.
head
head(
path: str,
*,
name: str | None = None
) -> Callable
Register a HEAD route.
options
options(
path: str,
*,
name: str | None = None
) -> Callable
Register an OPTIONS route.
websocket
websocket(
path: str,
*,
name: str | None = None
) -> Callable
Register a WebSocket route.
include_router
include_router(router: Router, prefix: str | None = None) -> None
Include routes from another router, optionally applying a mount prefix.
url_for
url_for(
name: str,
**params: Any
) -> str
Generate a URL for a named route.
OpenAPI Methods
enable_openapi
enable_openapi(
title: str = "Flaxon API",
version: str = "1.0.0",
description: str | None = None,
openapi_url: str = "/openapi.json",
docs_url: str | None = "/docs",
redoc_url: str | None = "/redoc",
include_internal: bool = False,
docs_guard: Callable[[Request], Any] | None = None,
protect_docs: bool = False,
persist_authorization: bool = False,
) -> Any
Register the generated OpenAPI JSON endpoint and interactive Swagger UI and
ReDoc pages. This is equivalent to passing openapi=True or an options mapping
to the constructor. See the OpenAPI guide.
Middleware Methods
add_middleware
add_middleware(
middleware_class: type[Any],
**options: Any
) -> None
Add middleware to the application.
ASGI Mounting
mount_asgi
mount_asgi(path: str, app: Any) -> None
Mount a foreign ASGI application such as FastAPI, Django ASGI, or an integration adapter under a path prefix. The mounted application owns its internal routing and protocol handling.
Template Methods
use_templates
use_templates(engine: Any) -> None
Configure Jinax template engine.
Lifecycle Methods
on_startup
on_startup(
callback: Callable[..., Any]
) -> Callable[..., Any]
Register a startup callback.
on_shutdown
on_shutdown(
callback: Callable[..., Any]
) -> Callable[..., Any]
Register a shutdown callback.
add_lifespan_context
add_lifespan_context(
factory: Callable[[], AbstractAsyncContextManager[Any]]
) -> Callable[[], AbstractAsyncContextManager[Any]]
Register an async context manager for a mounted ASGI application's startup and shutdown lifecycle. Contexts are entered before startup callbacks and exited after shutdown callbacks. FastMCP integrations use this method to initialize and close MCP session managers correctly.
Server Methods
run
run(
host: str = "127.0.0.1",
port: int = 8000,
*,
reload: bool = False,
workers: int = 1
) -> None
Run the application using Uvicorn.
Properties
routes
@property
def routes(self) -> list[Any]
Get all registered HTTP routes.
websocket_routes
@property
def websocket_routes(self) -> list[Any]
Get all registered WebSocket routes.
state
@property
def state(self) -> State
Get the application state container.
config
@property
def config(self) -> Config
Get the application configuration.
debug
@property
def debug(self) -> bool
Check if debug mode is enabled.
name
@property
def name(self) -> str
Get the application name.
Config
Configuration container.
Constructor
Config(
values: Mapping[str, Any] | None = None,
*,
prefix: str = "FLAXON_"
)
Config Methods
get_env
get_env() -> str
Get the current environment name.
is_development
is_development() -> bool
Check if the environment is development.
is_testing
is_testing() -> bool
Check if the environment is testing.
is_staging
is_staging() -> bool
Check if the environment is staging.
is_production
is_production() -> bool
Check if the environment is production.
is_debug
is_debug() -> bool
Check if debug mode is enabled.
get_secret_key
get_secret_key() -> str | None
Get the secret key.
get_allowed_hosts
get_allowed_hosts() -> list[str]
Get the list of allowed hosts.
get_max_body_size
get_max_body_size() -> int
Get the maximum body size in bytes.
to_dict
to_dict() -> dict[str, Any]
Convert configuration to a plain dictionary.
State
Application state container.
State Methods
get
get(
name: str,
default: Any = None
) -> Any
Get a state attribute with a default value.
setdefault
setdefault(
name: str,
default: Any
) -> Any
Set a state attribute if it does not already exist.
update
update(
**kwargs: Any
) -> None
Update state with multiple attributes.
to_dict
to_dict() -> dict[str, Any]
Convert state to a dictionary.
clear
clear() -> None
Clear all state attributes.
Use this capability in a full-stack app
Flaxon serves Python APIs and Teloce interfaces in one project. Keep validation, authorization and privileged operations on the server; components call those endpoints and present their results. Follow the full-stack lessons and Teloce integration reference to connect this capability to pages, components and application modules.