jeudi 1 octobre 2020

app#get() not doing anything, (node.js + express.js)

i recently today wanted to switch to express 4.x scince i've been working with 3.x a longer time than needed.

Basically i made a very simple application but the app#get() is not working at all!

this is my code:


/** Declaring constants */
const config = require( "./config.json" );
const methods = require( "./depending_methods.js" );

const sessions = new Map( );

const express = require( "express" );
const path = require( "path" );
const bodyParser = require( "body-parser" );
const app = express();


let currentdata;

/**
 * some mongodb stuff ##redacted
 */

/** Configuration Express + HBS and Middleware */
    app.use(require('morgan')("dev"))
    app.use(bodyParser.json());
    app.use(require( "cookie-parser" ));
    app.use(express.static('static'));
    app.use('./views', express.static(path.join(__dirname, './views')));
    app.use(express.static(path.join(__dirname, './views')));
    app.use(bodyParser.urlencoded({ extended: false }));
    app.set('view engine', 'hbs');
    app.set('views', path.join(__dirname, 'views'));

    require('hbs').registerHelper(require('handlebars-helpers')());


    console.log("registered get()")
app.get("/", function(req, res) {
    console.log("triggered /");
    res.send("Hey");
})


/** Configure port and start the Server! */
app.listen(config.port);
console.log("skynet is on: http://127.0.0.1:" + config.port + "/");

The "triggered /" does not happen, but the "registered get()" does.

I also get the obligatory "GET / - - ms - -" in the console

what did i do wrong?




Aucun commentaire:

Enregistrer un commentaire