Web Server - me2d13/luamacros GitHub Wiki
A webpage can be created to interact with LUAMacros via HTTP messages to a webserver running on the host machine.
Some basic testing can be done with this snippet
lmc_http_server(12345, function(url)
print('Callback for ' .. url)
end)
This will log the callback used, which we can use to interact with our code.
For example, sending a message to http://localhost:12345/pressabutton
will return a callback with the string pressabutton
With this, we can use this variable to run functions or other code
lmc_http_server(12345, function(url)
if url == '/beacon_on' then
print('turning the beacon on')
elseif url == '/beacon_off' then
print('turning the beacon off')
else
print('Unimplemented callback for ' .. url)
end
end)
A basic HTML page can be constructed to send these messages
<html>
<a href="http://localhost:12345/beacon_on">Beacon on</a>
<a href="http://localhost:12345/beacon_off">Beacon off</a>
</html>
Even moreso, messages can be returned to the browser for AJAX development
return '{"Foo": "bar"}', 'application/json'
A better rundown of tutorial code can be read Here