Plugins
Flaxon provides a plugin system that allows you to extend the framework with modular components.
Available Plugins
Official Flaxon plugins with Three.js powered previews.
Creating a Plugin
Flaxon plugins are simple Python classes that extend the framework.
from flaxon.plugins import Plugin
class MyPlugin(Plugin):
name = "my-plugin"
version = "1.0.0"
description = "A custom Flaxon plugin"
def setup(self, app):
@app.get("/plugin")
async def plugin_route():
return {"plugin": "MyPlugin"}
app.add_middleware(MyPluginMiddleware)
app.state.plugin_loaded = True
Simple Plugin
from flaxon.plugins import SimplePlugin
def setup_plugin(app):
@app.get("/simple")
async def simple_route():
return {"plugin": "Simple"}
plugin = SimplePlugin("simple-plugin", setup_plugin)
Plugin Lifecycle
class LifecyclePlugin(Plugin):
name = "lifecycle-plugin"
version = "1.0.0"
def on_load(self):
print("Plugin loaded")
def setup(self, app):
print("Plugin setup")
def on_startup(self):
print("Plugin startup")
def on_shutdown(self):
print("Plugin shutdown")
def on_unload(self):
print("Plugin unloaded")
Plugin Dependencies
class CorePlugin(Plugin):
name = "core-plugin"
version = "1.0.0"
provides = ["database", "cache"]
class DatabasePlugin(Plugin):
name = "database-plugin"
version = "1.0.0"
requires = ["core-plugin"]
provides = ["postgres"]
Tip
Plugins can add routes, middleware, CLI commands, health checks, and lifecycle hooks.