23.07.2020, 11:25
(07.07.2020, 07:13)admin Wrote: You don't need a script to create a web server, you can use LM web server's .lp scripts for this task.
1. Disable password access to User directory in User access settings.
2. Upload the example as rfid.lp using FTP apps login into user directory. You can check if the file can be accessed by opening http://LM_IP/user/rfid.lp, you should see a blank page but not a 404 error.
3. In your RFID reader set HTTP notification port to 80 and path to /user/rfid.lp
This example is only a starting point, you need to modify it to check the requested function type and provide a correct response depending on the request. If request is a valid JSON it will be visible in Logs tab in LM.
Code:<?
require('apps')
post = ngx.req.get_body_data()
header('content-type', 'application/json')
if post then
data = json.pdecode(post)
if data then
log(data)
print(json.encode({
date = "2020-07-05 07:35:54",
interval = 10,
messages = {
{
id = 123456789,
operation = "set_active",
active = 1,
online = 1
}
}
}))
end
end
Apps documentation: https://forum.logicmachine.net/showthread.php?tid=85
Thank you very much, it was very helpful.
The solution using the application is much easier.