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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:46:37+00:00 2026-06-02T03:46:37+00:00

I have this code ( https://gist.github.com/2402116 ) : server.get(‘/’, function(request, response) { var k

  • 0

I have this code (https://gist.github.com/2402116) :

server.get('/', function(request, response) {
 var k = fs.readFileSync('./index.html','utf8');
 response.send( k );
});

Tries to read this file:

https://gist.github.com/2402070

and the browser keeps loading and never end.

But if I remove all the js includes from the html file works fine.

what am I doing wrong?

  • 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-02T03:46:39+00:00Added an answer on June 2, 2026 at 3:46 am

    Your current server implementation does not do anything but serve index.html to requests for the base url, i.e. '/'. You will need to write further code/routes to serve the requests for the js includes in your index.html, i.e. '/app.js' and the various js files in '/js/'.

    Now, the routing implementation in the gist is quite crude and doesn’t support many aspects of url matching. The original code is clearly just demonstrating a concept for a single page site with no resources. You will see it will quickly become burdensome to get your code working as you will effectively have to write a route for every resource request, e.g.

    server.get('/app.js', function(request, response) {
      var k = fs.readFileSync('./app.js','utf8');
      response.send( k );
    });
    
    server.get('/js/jquery-1.7.2.js', function(request, response) {
      var k = fs.readFileSync('./js/jquery-1.7.2.js','utf8');
      response.send( k );
    });
    
    etc...
    

    You are better off looking at a node.js url routing library already out there (e.g. director) or a web framework such as express which has inbuilt support for routing (and static file serving).

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

Sidebar

Related Questions

Folks, I have this code https://gist.github.com/2473387 But, how do I get the coordinates of
I have this code working in C#: var request = (HttpWebRequest)WebRequest.Create(https://x.com/service); request.Method = GET;
This is PHP code I have so far: https://gist.github.com/2eeba2ff31ebecb526e2 This is the result: https://gist.github.com/cf07fe90922ac3dfcd22
I'm seeing a really weird issue with this code and sample execution: https://gist.github.com/720278 The
I have this code: $(document).ready(function() { var url = https://graph.facebook.com/search?q=cinema&type=post; $.ajax({ type: POST, url:
I have this code: function submitTwice(f){ f.action = 'http://mydomain.com/threevideopage.php'; f.target='name'; f.submit(); } I left
I have this code require 'mechanize' @agent = Mechanize.new page = @agent.get('http://something.com/?page=1') next_page =
UPDATE 9th june 2012: Setup with mongoid 3.0.0.rc at heroku, see this gist: https://gist.github.com/2900804
The complete code is on https://gist.github.com/1341623 I'd like to sort an index array (or
I have this code: <script type=text/javascript> $(document).ready(function() { var url = https://graph.facebook.com/search?q=cinema&type=post; $.ajax({ type:

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.