2
I have a main.js file with routes to html files, but I would also like to add a route to a javascript file.
In the main.js file I have the following code.
const express = require("express");
const app = express();
const rootRoute = __dirname + '/';
app.get('/', function(request, response){
response.sendFile('js/index.js');
});
app.listen(3000, function(){
console.log("A aplicação está rodando em: http://localhost:3000")
});
The problem is not to find the file, the file is found, but the command is not executed, it is only printed, as if it were a message sent by the route’s Response send method.
This file should only run the script contained in it, nothing else.
I’ve tended the method to yield, but he was depreciated, after that I found no other solution.
Obs.: the function is working perfectly as I have already tested in this file main.js