Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8146761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:06:42+00:00 2026-06-06T14:06:42+00:00

Well – the more I read the more confused I get. So here the

  • 0

Well – the more I read the more confused I get. So here the source:

var express = require('express')
  , http = require('http')
  , server = express()
  ;

var home = require('./routes/home.js')
  , about = require('./routes/about.js')
  , contact = require('./routes/contact.js');

  server.configure(function () {
  server.set('port', process.env.PORT || 3000);
  server.set('view engine', 'hjs');
  server.set('views', __dirname + '/views');
  server.use(express.logger());
  server.use(server.router);
  server.use(express.favicon());
  server.use(require('stylus').middleware(__dirname + '/public'));
  server.use(express.static(__dirname + '/public'));
  server.use(express.bodyParser());
  server.use(express.cookieParser('your secret here'));
  server.use(express.methodOverride());
  server.use(express.session());
});

server.get('*', function (req, res) {
  switch (req.path) {

    case '/':
      res.render('home', { title:'Home Page' });
      break;

    case '/about/':
      res.render('home', { title:'About Page' });
      break;

    case '/contact/':
      res.render('contact', { title:'Contact Page' });
      break;

    default:
      res.render('home', { title:'404 - Page not found'});
  }
});

Well it’s working, but I still don’t get that req/res combo into my skull.
I’m pretty sure I don’t need '*' there as a parameter. However I don’t know how to
build up a better solution. Any simple dumb stupid exmaples so I could visualize how
exactly the magic works.

To simplify my riddle I’d like to know (and understand) why this works:

server.get('*', function (req, res) {

but this doesn’t

server.get(function (req, res) {

the first parameter is always being handled as what exectly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:06:44+00:00Added an answer on June 6, 2026 at 2:06 pm

    I believe the first parameter is the route. You can break up your code into the following which might make more sense, and would follow convention:

    server.get('/', function (req, res) {
        res.render('home', { title:'Home Page' });
    })
    
    server.get('/contact/', function (req, res) {
        res.render('contact', { title:'Contact Page' });
    });
    
    server.get('*', function (req, res) {
        res.render('Page Not Found', 404);
    });
    

    And so forth…

    The '*' that you are using just accepts all routes. Similar to a wildcard!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, I downloaded Rijndael sources from here: http://www.codeproject.com/Articles/1380/A-C-Implementation-of-the-Rijndael-Encryption-Decr I have the following code: int
Well, my website can not redirect to https://www.facebook.com/QuaFootSpa from http://quafootspa.com/ I have tried redirection
Well im here because i have a problem. i have code that was created
Well, sorry for the question, is more like a general culture one (haven't found
Well, I have to revive a question that was answered here before. I've made
Well, I got problem here with opengl ES stuff (just started to learn about
Well, having decided to get to know some of the basic functions in R
Well, I believe the title is pretty straight forward. I've read many times that
Well, here's what I have to do. I need to trim the whitespaces in
Well, I just started to work on server side scripting , I chose PHP,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.