Reloading the page in Express / nodejs

0

I created a new project with Express and Nodejs, where I defined a "/ status" route. Each time this route is accessed, you should run a routine in the /routes/status.js script. Example: If I run an F5 in the browser with the address http://192.168.137.2:3000/status , it would have to execute /routes/status.js , but this does not happen.

I imagine that this is behavior is the natural of Express. However, how do I get it to run in this way that I have described or otherwise in any way?

    
asked by anonymous 20.07.2017 / 00:19

1 answer

0

You are using some module to load your route, otherwise I indicate a so-called consign. You will install via npm

npm install --save consign

It will matter to your application

var consign = require('consign');

Set where the routes will be

consign()
.include('app/routes')
.into(app)

And will normally create your own status.js receiving

module.exports = function(app){
app.post('/status', function(req, res){
    //aqui vc direciona para sua view       
})

}

    
20.07.2017 / 00:50