Created
June 3, 2016 16:48
-
-
Save craftbyte/6807882d1bb651b379c6a52cc105a7ce to your computer and use it in GitHub Desktop.
Issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express') | |
var morgan = require('morgan') | |
var MikroNode = require('mikronode-ng'); | |
var app = express() | |
var connection = new MikroNode.Connection('192.168.1.99','admin','admin', {closeOnDone : true}); | |
app.use(morgan("dev")) | |
app.use(express.static('static')) | |
app.set("view engine", "pug") | |
app.get("/", (req,res) => { | |
res.render('index') | |
}) | |
app.get('/data', (req,res) => { | |
connection.getConnectPromise().then(function(conn) { | |
conn.closeOnDone = true; | |
conn.getCommandPromise('/ip/firewall/address-list/print').then(function resolved(values) { | |
res.send(JSON.stringify(values)); | |
}, function rejected(reason) { | |
res.send(JSON.stringify(reason)); | |
}); | |
}, function reject(result) { | |
console.log(result); | |
}); | |
}) | |
app.post('/data', (req,res) => { | |
connection.getConnectPromise().then(function (conn) { | |
conn.closeOnDone = true; | |
console.log(123) | |
conn.getCommandPromise(['/ip/firewall/address-list/add', '=list=allowed', '=address=2.0.1.222', '=comment=Made']).then(function resolved(values) { | |
res.send(JSON.stringify(values)); | |
}, function rejected(reason) { | |
res.send(JSON.stringify(reason)); | |
}); | |
}, function reject(result) { | |
console.log(result); | |
}) | |
}) | |
var port = 3000 | |
app.listen(port, _ => { | |
console.log("Running on", port) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment