Extensions
Add your own HTML, styles and server code to LessCode with files in the extensions folder.
On this page
An extension is an HTML file in the extensions folder of LessCode. When the flow starts, LessCode loads every .html file there:
- The part inside
<script total>runs on the server, once, when the flow starts. - The rest of the file (HTML,
<style>and normal scripts) is added to the designer page.
The folder does not exist in a new installation. Create it next to index.js. Do not remove the file extensions.js: it loads your extensions.
Example
This file adds an endpoint that reports the uptime of the server, and an orange line under the designer toolbar.
1. Create the file extensions/status.html:
<script total>
ROUTE('GET /api/status/', $ => $.json({ name: exports.name, flow: exports.flow.id, uptime: Math.round(process.uptime()) }));
</script>
<style>
.fheader { border-bottom: 3px solid #E8A317; }
</style>2. Restart LessCode.
3. Call the endpoint:
curl http://localhost:8000/api/status/The answer looks like this:
{"name":"status","flow":"lesscode","uptime":4}The designer shows the orange line under the toolbar:

What the server part can use
| Name | Value |
|---|---|
exports.name | The file name without .html. |
exports.id | The same as exports.name. |
exports.flow | The running flow. |
Changes
LessCode reads the folder when the flow starts. After you add, change or remove an extension, restart LessCode.