json api to read current universe state
This commit is contained in:
parent
cfd3e6f482
commit
4f188f06b3
1 changed files with 15 additions and 2 deletions
13
dmx-web.js
13
dmx-web.js
|
@ -56,6 +56,19 @@ function DMXWeb() {
|
|||
res.sendfile(__dirname + '/index.html')
|
||||
})
|
||||
|
||||
app.get('/state/:universe', function(req, res) {
|
||||
if(!(req.params.universe in dmx.universes)) {
|
||||
res.status(404).json({"error": "universe not found"})
|
||||
return
|
||||
}
|
||||
var universe = dmx.universes[req.params.universe]
|
||||
var u = {}
|
||||
for(var i = 0; i < 256; i++) {
|
||||
u[i] = universe.get(i)
|
||||
}
|
||||
res.json({"state": u})
|
||||
})
|
||||
|
||||
app.post('/animation/:universe', function(req, res) {
|
||||
try {
|
||||
var universe = dmx.universes[req.params.universe]
|
||||
|
|
Loading…
Reference in a new issue