You can use waffle . Here is an example greeting on this page:
local app = require('waffle') app.get('/', function(req, res) res.send('Hello World!') end) app.listen()
lets say that your algorithm is a simple face detector. The input is an image, and the output is face detection in some json format. You can do the following:
local app = require('waffle') require 'graphicsmagick' require 'MyAlgorithm' app.post('/', function(req, res) local img, detections, outputJson img = req.form.image_file:toImage() detections = MyAlgorithm.detect(img:double()) outputJson = {} if (detections ~= nil) then outputJson.faceInPicture = true outputJson.faceDetections = detections else outputJson.faceInPicture = false outputJson.faceDetections = nil end res.json(outputJson) end) app.listen()
Thus, your algorithm can be used as an independent service.
source share