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 8112831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:38:31+00:00 2026-06-06T02:38:31+00:00

I have a basic expressjs app (using jade), but I am having trouble rendering

  • 0

I have a basic expressjs app (using jade), but I am having trouble rendering basic Jade files. When I get a request, i parse the url for the pathname and use the handle object to route the request as follows:

index.js

var requestHandlers = require('./requestHandlers');

var handle = {};
handle['/'] = requestHandlers.start;
handle['/download'] = requestHandlers.download

requestHandlers.js

   function start(res) {
        console.log("request handler for start called");
        res.render('home', {title: 'express'});
    }

    function download(res) {
        res.render('download', {title: 'download'})
        res.end();
    }

    exports.start = start;
    exports.download = download;

home.jade

h1= title
p Welcome to #{title}

I am using Jade as my templating engine, and have configured the server in a seperate server.js file. When i request either of the pages, the title displays correctly on my browser tab, but the page doesn’t display, it just keeps loading. Weirdly, when I cancel the request the page displays. It’s as if everything works but nothing tells the process to end?

I am relatively new to node so excuse my naiveté on any of the above. Let me know if there are any questions I can clear up.

  • 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-06T02:38:33+00:00Added an answer on June 6, 2026 at 2:38 am

    I’m not 100% positive why your code isn’t killing the TCP connection as needed to prevent your browser from timing out, but I can provide a solution that is friendly towards Express conventions that should solve your issues and maintain code readability, maintainability, and separation.

    ./app.js (your main server script)

    var express = require('express'),
        app = express.createServer(),
        routes = require('./routes');
    
    app.configure(function () {
    
        // Render .jade files found in the ./views folder
        // I believe you are already doing this
        app.set('views', __dirname + '/views');
        app.set('view engine', 'jade');
    
        // Use the built-in Express router
        // This kills the "handle" method you had implemented
        app.use(app.router);
    
        // Client-side assets will be served from a separate ./public folder
        //     i.e. http://yourhost.com/js/main.js will link to ./public/js/main.js
        app.use(express.static(__dirname + '/public'));
    
    });
    
    // Initialize routes
    routes.init(app);
    

    ./routes/index.js

    exports.init = function (app) {
    
        app.get('/', function (req, res) {
            console.log("request handler for start called");
    
            // Render __dirname/views/home.jade
            res.render('home', {title: 'express'});
        });
    
        app.get('/download', function (req, res) {
            // Render __dirname/views/download.jade
            res.render('download', {title: 'download'})
        });
    
    });
    

    The above prevents you from needing to parse the URL parameters by yourself. Also you can define more readable and powerful request handlers (i.e. app.post for POST methods). You are now enabled to more easily tie in things like the Express-Resource module if you decide to build a REST API.

    If you need more powerful mappings you can use regular expressions in the first parameter of app.[get/post/put/del] to filter for specific paths instead.

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

Sidebar

Related Questions

I have a basic Node.js app that I am trying to get off the
I'm using node, express and connect for a simple app and have basic HTTP
I'm using Visual Basic 2010 Express. I have a form that can be minimized.
Possible Duplicate: Publish WCF Service app on IIS Express using Web Deployment I have
I have a basic Express server: // server.js: var Express = require('express'); app =
I want to add video in my app . But i have a problem
I am using Microsoft Visual Basic 2010 Express. I have a WPF-based project. I
I'm using Microsoft Visual Basic 2008 Express Edition. I have a Folder Dialog Browser
I have a basic, simple and maybe stupid question, but how do I implement
I have a basic Socket.io server setup like this: var server = express.createServer().listen(port); this.io

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.