Currently as it stands the request is not being closed after the state of 
the gpio pin has been changed. You need to call something like 
res.send('gpio pin: 7 is now on') after it is closed

You can also simplify what you have down to something like


> *var allowedPins = ['7','11', '16'];app.post('/:pin/:state', function(req, 
> res) {  var pin = req.params.pin;  var state = req.params.state;  if 
> (allowedPins.indexOf(pin) != -1 && state === '0' || state == '1'){    
> gpio.open(pin, 'output', function(err){      if (err) {        
> res.send(err);        return;      }      gpio.write(pin, 1, function() {  
>         gpio.close(pin);          res.send('success')      });    });  } 
> else {    res.send('error')  }});*
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/78b2eac8-1caf-4bf5-90e2-82380fbd4eb7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to