Commit 8ee109bb9a5400e31b72e1df258d210cf7b3cb25
1 parent
d12974b5
Exists in
master
Corrigido nome da chamada ao arquivo python no servidor
Showing
3 changed files
with
7 additions
and
12 deletions
Show diff stats
endpoints/sinal.js
| 1 | 1 | var uuid = require('node-uuid'); |
| 2 | 2 | var API = require('../db/api'); |
| 3 | 3 | |
| 4 | -function init_endpoint(req, res, Sign) { | |
| 4 | +function init_endpoint(req, res, Sign, Status) { | |
| 5 | 5 | /* Verifica se o paramêtro [name] existe ou possui algum valor */ |
| 6 | 6 | if ((req.body.userId === '') || (req.body.userId === undefined)) { |
| 7 | 7 | res.send(500, { 'error': 'Especifique o usuário'}); |
| 8 | 8 | return; |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | - var array = ['Sucesso', 'Falhou', 'Processando'] | |
| 12 | - | |
| 13 | 11 | var sign_object = new Sign({ |
| 14 | 12 | name: req.body.userId, |
| 15 | 13 | uuid: uuid.v4(), |
| 16 | 14 | created_at: new Date(), |
| 17 | 15 | updated_at: new Date(), |
| 18 | - status: array[Math.floor(Math.random() * array.length)] | |
| 16 | + status: Status | |
| 19 | 17 | }); |
| 20 | 18 | |
| 21 | 19 | API.create(sign_object, function(result) { | ... | ... |
public/assets/js/main.js
server.js
| ... | ... | @@ -34,14 +34,15 @@ app.get('/signs', function(req, res) { |
| 34 | 34 | res.sendfile('views/index.html'); |
| 35 | 35 | }); |
| 36 | 36 | |
| 37 | -app.post('/sinal', function(req, res) { | |
| 37 | +app.post('/sign', function(req, res) { | |
| 38 | 38 | options.args = JSON.stringify(req.body); |
| 39 | - PythonShell.run('Controller.py', options, function (err, results) { | |
| 40 | - if (err) { console.log(err); res.send(400); return; } | |
| 39 | + PythonShell.run('controller.py', options, function (err, results) { | |
| 40 | + if (err) { console.log(err); endpoint_sinal.init(req, res, Sign,"Falhou"); res.send(400); return; } | |
| 41 | 41 | // results is an array consisting of messages collected during execution |
| 42 | - endpoint_sinal.init(req, res, Sign); | |
| 42 | + endpoint_sinal.init(req, res, Sign,"Sucesso"); | |
| 43 | 43 | res.send(200); |
| 44 | 44 | }); |
| 45 | + | |
| 45 | 46 | |
| 46 | 47 | }); |
| 47 | 48 | ... | ... |