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 | var uuid = require('node-uuid'); | 1 | var uuid = require('node-uuid'); |
2 | var API = require('../db/api'); | 2 | var API = require('../db/api'); |
3 | 3 | ||
4 | -function init_endpoint(req, res, Sign) { | 4 | +function init_endpoint(req, res, Sign, Status) { |
5 | /* Verifica se o paramêtro [name] existe ou possui algum valor */ | 5 | /* Verifica se o paramêtro [name] existe ou possui algum valor */ |
6 | if ((req.body.userId === '') || (req.body.userId === undefined)) { | 6 | if ((req.body.userId === '') || (req.body.userId === undefined)) { |
7 | res.send(500, { 'error': 'Especifique o usuário'}); | 7 | res.send(500, { 'error': 'Especifique o usuário'}); |
8 | return; | 8 | return; |
9 | } | 9 | } |
10 | 10 | ||
11 | - var array = ['Sucesso', 'Falhou', 'Processando'] | ||
12 | - | ||
13 | var sign_object = new Sign({ | 11 | var sign_object = new Sign({ |
14 | name: req.body.userId, | 12 | name: req.body.userId, |
15 | uuid: uuid.v4(), | 13 | uuid: uuid.v4(), |
16 | created_at: new Date(), | 14 | created_at: new Date(), |
17 | updated_at: new Date(), | 15 | updated_at: new Date(), |
18 | - status: array[Math.floor(Math.random() * array.length)] | 16 | + status: Status |
19 | }); | 17 | }); |
20 | 18 | ||
21 | API.create(sign_object, function(result) { | 19 | API.create(sign_object, function(result) { |
public/assets/js/main.js
@@ -61,10 +61,6 @@ var Main = function() { | @@ -61,10 +61,6 @@ var Main = function() { | ||
61 | case 'Falhou': | 61 | case 'Falhou': |
62 | $(array[i]).addClass('_error'); | 62 | $(array[i]).addClass('_error'); |
63 | break; | 63 | break; |
64 | - | ||
65 | - case 'Processando': | ||
66 | - $(array[i]).addClass('_processing'); | ||
67 | - break; | ||
68 | } | 64 | } |
69 | } | 65 | } |
70 | 66 |
server.js
@@ -34,14 +34,15 @@ app.get('/signs', function(req, res) { | @@ -34,14 +34,15 @@ app.get('/signs', function(req, res) { | ||
34 | res.sendfile('views/index.html'); | 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 | options.args = JSON.stringify(req.body); | 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 | // results is an array consisting of messages collected during execution | 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 | res.send(200); | 43 | res.send(200); |
44 | }); | 44 | }); |
45 | + | ||
45 | 46 | ||
46 | }); | 47 | }); |
47 | 48 |