Commit 8ee109bb9a5400e31b72e1df258d210cf7b3cb25

Authored by FrancoNeto
1 parent d12974b5
Exists in master

Corrigido nome da chamada ao arquivo python no servidor

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
... ... @@ -61,10 +61,6 @@ var Main = function() {
61 61 case 'Falhou':
62 62 $(array[i]).addClass('_error');
63 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 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  
... ...