Create custom endpoints and routes with Quart blueprint plugins
Blueprint plugins allow you to add custom HTTP endpoints to Ayase Quart using Quart Blueprints. This enables you to extend the application with custom functionality, APIs, or integrations.
Your module must export a Blueprint instance named bp:
from quart import Blueprint# The module must have a Blueprint named 'bp'bp = Blueprint( 'my_blueprint', __name__, static_folder='../static', static_url_path='/static/plugins')@bp.get('/my-custom-endpoint')async def my_custom_endpoint(): return {'message': 'Hello from my plugin!'}, 200@bp.post('/my-api')async def my_api(): return {'status': 'success'}, 200
3
Enable plugins in config
Make sure plugins are enabled in your config.toml:
[search_plugins]enabled = true
4
Restart Ayase Quart
Restart the application to register your blueprint. You should see:
Loading bp plugin: ayase_quart.plugins.blueprints.my_blueprint
Here’s the complete example from src/ayase_quart/plugins/blueprints/bp_example.py:
from quart import Blueprint# This module must have a Blueprint named bp# static_folder is relative to this module# static_url_path cannot be '/static'bp = Blueprint( 'bp_example', __name__, static_folder='../static', static_url_path='/static/plugins',)# You are responsible for any endpoint collisions@bp.get('/health_plugin_blueprint')async def health_plugin_blueprint(): return '<link rel="stylesheet" href="/static/plugins/example.css"> ok', 200
The example is wrapped in if 0: to maintain syntax highlighting without loading it by default. Remove this condition in your actual plugin.
You can import and use the database connections from Ayase Quart:
from quart import Blueprintfrom ...db import db_qbp = Blueprint('db_plugin', __name__)@bp.get('/custom-query')async def custom_query(): async with db_q.pool.acquire() as conn: result = await conn.fetch('SELECT * FROM posts LIMIT 10') return {'posts': [dict(r) for r in result]}, 200