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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:14:36+00:00 2026-05-27T12:14:36+00:00

I have following setup in cloud9 IDE. Project root folder Hello.html – contains simple

  • 0

I have following setup in cloud9 IDE.

Project root folder

  1. Hello.html – contains simple html tags (+image tag) Preview displays the image
  2. HelloHtml.js – node js file that reads html file and writes to the client (response). .
  3. Penguins.jpg – image file in the same folder.

When I run the service and hit the URL in browser, HTML gets rendered with “Hello World!” being displayed as . But the image is not getting rendered. What should be the src=”” attribute in the img tag.

What should be the path for the image file? Thank you.

HelloHtml.js

var http = require('http');
var fs = require('fs');

http.createServer(function(request, response) {
    response.writeHead(200, {
        'Content-Type': 'text/html'
    });
    fs.readFile('./Hello.html', function(err, data){
            if(err) throw err;
            response.end(data);
        });
}).listen(process.env.PORT); 
console.log('Hello World HTML Service has started.');

Hello.html

<html>
    <head>
        <title>Node JS</title>
    </head>
    <body>
        <h2>Hello world!</h2>
        <img src="Penguins.jpg" />
    </body>
</html>
  • 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-05-27T12:14:36+00:00Added an answer on May 27, 2026 at 12:14 pm

    You are not handling static files serving anywhere in your code, you are just serving the file ‘hello.html’ no matter what:

    http.createServer(function(request, response) {
        response.writeHead(200, {
            'Content-Type': 'text/html'
        });
        fs.readFile('./Hello.html', function(err, data){
                if(err) throw err;
                response.end(data);
            });
    }).listen(process.env.PORT); 
    

    Either make a routing scheme, based on the request url or use some static file server from here:

    https://github.com/joyent/node/wiki/modules#wiki-web-frameworks-static

    I suggest you take a look at Express, it has that and route handling also: expressjs.com

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

Sidebar

Related Questions

I have the following setup: eclipse a standard Java project (A) an eclipse plugin
I have the following setup on 2 div tags: <div id='div1' style='position: absolute; z-index:
I have a simple console application where I have the following setup: public interface
I am working on my first NHibernate project, and have the following setup/requirement. I
I have the following setup: ASP.net 3.5 Web Site Project C# Class Library with
I have the following setup: Main assembly that contains a WcfService and IWcfService contract.
I have the following setup: Project A Project B depends on A Each project
I have following setup: html: <div id=holder> <div> <img/> <img/> </div> </div> css #holder
Say I have the following setup: Page1.html Includes master.css, page1.css and page1.js Page2.html Includes
I have the following setup for a simple application: generated LINQ to SQL classes

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.