Hi.

Im obviously not an experienced python or nodejs programmer.  


I have a working app on a raspberrypi which takes a POST request from a 
server and does something like this (full code 
here:https://github.com/quique123/aismarthome/blob/master/app.js):

app.post('/api/switches/:id', function(req, res){
  if (req.query.password === process.env.PASS){
    var foundSwitch = getSwitch(req.params.id);
    if(!(req.query.command === "on" || req.query.command === "off")){
      foundSwitch.toggle();
    } else {
      foundSwitch.setState(req.query.command)
    }
    saveState();
    console.log("postSwitch "+JSON.stringify(foundSwitch));
    res.json(foundSwitch);
  } else {
    console.log("invalid password")
    res.send("try again")
  }
})


and I tried combining it with a pure nodejs script which looks like this 
(full script here: 
https://github.com/quique123/mygennie/blob/master/app.js):

app.post('/', function (request, response) {
 console.log('headers: ' + JSON.stringify(request.headers));
 console.log('body: ' + JSON.stringify(request.body));
 const assistant = new Assistant({request: request, response: response});

 function generateAnswer(assistant) {
    assistant.data.answer = 33;
    assistant.ask('I\'m thinking of a number from 0 and 100. What\'s your 
first guess?');
 }
 function checkGuess(assistant) {
      console.log('checkGuess');
 }
 let actionMap = new Map();
 actionMap.set(GENERATE_ANSWER_ACTION, generateAnswer);
 actionMap.set(CHECK_GUESS_ACTION, checkGuess);
 assistant.handleRequest(actionMap);
});


I ended up with this full script 
here https://github.com/quique123/myjsonparser/blob/master/app.js


Im running it in heroku but I get an error like this:

2017-04-30T15:12:25.722224+00:00 app[web.1]: npm ERR!     node app.js
>
> 2017-04-30T15:12:25.722325+00:00 app[web.1]: npm ERR! You can get information 
> on how to open an issue for this project with:
>
> 2017-04-30T15:12:25.722425+00:00 app[web.1]: npm ERR!     npm bugs 
> number-genie
>
> 2017-04-30T15:12:25.722627+00:00 app[web.1]: npm ERR! Or if that isn't 
> available, you can get their info via:
>
> 2017-04-30T15:12:25.722711+00:00 app[web.1]: npm ERR!     npm owner ls 
> number-genie
>
> 2017-04-30T15:12:25.722798+00:00 app[web.1]: npm ERR! There is likely 
> additional logging output above.
>
> 2017-04-30T15:12:25.725968+00:00 app[web.1]: 
>
> 2017-04-30T15:12:25.726116+00:00 app[web.1]: npm ERR! Please include the 
> following file with any support request:
>
> 2017-04-30T15:12:25.726177+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
>
> 2017-04-30T15:12:25.824126+00:00 heroku[web.1]: State changed from starting 
> to crashed
>
> 2017-04-30T15:12:25.811765+00:00 heroku[web.1]: Process exited with status 1
>
>
Please help

-- 
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/1a7dc67b-adf1-4a1e-a22d-0afa6337403b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to