diff options
author | 2016-02-14 19:48:44 +0100 | |
---|---|---|
committer | 2016-02-14 19:48:44 +0100 | |
commit | 686ba42466ca46f9e49f13d45ae9a225aa2dbe51 (patch) | |
tree | 209ff8b5e73b3ffe44c05cc73cd764c8768b9e0a /plugins/webserver/init.lua | |
parent | 5a31d8513b9bc63637aa50bffb59d4ce1c246029 (diff) |
Added plugin info json files and made system automatically load available plugins and start them if flagged so (nw)
Diffstat (limited to 'plugins/webserver/init.lua')
-rw-r--r-- | plugins/webserver/init.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/plugins/webserver/init.lua b/plugins/webserver/init.lua new file mode 100644 index 00000000000..3d68b01e6d5 --- /dev/null +++ b/plugins/webserver/init.lua @@ -0,0 +1,34 @@ +local exports = {} +exports.name = "webserver" +exports.version = "1.0.0" +exports.description = "A simple web server" +exports.license = "MIT" +exports.author = { name = "Miodrag Milanovic" } + +local ws = exports + +local app = require('weblit/app') + +function ws.startplugin() + app.bind({ + host = "0.0.0.0", + port = 8080 + }) + + app.use(require('weblit/logger')) + app.use(require('weblit/auto-headers')) + app.use(require('weblit/etag-cache')) + + app.route({ + method = "GET", + path = "/", + }, function (req, res, go) + res.code = 200 + res.headers["Content-Type"] = "text/html" + res.body = "<h1>Hello!</h1>\n" + end) + + app.start() +end + +return exports |