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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:23:31+00:00 2026-06-10T21:23:31+00:00

I wrote a simple HTTP sever that serves some HTML. Here’s the code :

  • 0

I wrote a simple HTTP sever that serves some HTML.
Here’s the code :

var http = require('http');

http.createServer(function(req, res) {

  res.writeHeader(200, {"Content-Type": "text/html"});

  var html = '<DOCTYPE!>' +
    '  <html>' +
    '    <head>' +

    '      <title>' +
    '        Test page' +
    '      </title>' +

    '    </head>' +
    '  <body>' +

    '    <p>' +

    '      This is a test page !' +

    '    </p>' +

    '  </body>' +
    '  </html>';

  res.write(html);

  res.end();

}).listen(8080);

The resulting HTML page is the following :

<html>
<head>
</head>
<body>
<doctype!>
<title> Test page </title>
<p> This is a test page ! </p>
</doctype!>
</body>
</html>

So my questions are the following :

  • Why is the html “string” included in the body of the HTML ?
  • Is it possible to have indentation in the HTML besides using a template engine (jade) ?

And the last question is a bit separate :

  • If I have a page called index.html which only shows img.jpg. How can I know that a users request to img.jpg is related to index.html ?
    What I mean by “related” is : “that img.jpg is a linked / a dependency of index.html“.

Thank you in advance !

  • 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-10T21:23:32+00:00Added an answer on June 10, 2026 at 9:23 pm

    Why is the html “string” included in the body of the HTML ?

    That’s because <DOCTYPE!> isn’t valid. It should be:

    <!DOCTYPE html>
    

    As is, it appears more like an element to the browser, which attempts to normalize the markup and places it into the <body>.


    Is it possible to have indentation in the HTML besides using a template engine (jade) ?

    Many template engines, including Jade, actually minify the markup, removing all unnecessary whitespace for smaller bandwidth consumption.

    But, you could look at using a “beautifier,” such as html.


    If I have a page called index.html which only shows img.jpg. How can I know that a users request to img.jpg is related to index.html ? What I mean by “related” is : “that img.jpg is a linked / a dependency of index.html”.

    You can view “Resources” in most in-browser debuggers, which will list images, scripts, stylesheets, etc. that your page has requested.

    You could also try web scraping your application, perhaps with jsdom:

    jsdom.env('http://localhost:8080/', [
        'http://code.jquery.com/jquery.min.js'
    ],
    function (err, window) {
        var $ = window.$;
    
        var hrefs = $('a[href]').map(function () {
            return $(this).attr('href');
        }).get();
        console.log(hrefs);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote some simple application that make http call ( Post ). The Response
I wrote a simple function, that makes emacs add matching quotes (so when I
I wrote a simple plugin which sets some css code using wp_options. It all
Below is my simple asp code that I am using to insert some data
I want to create a simple http proxy server that does some very basic
I wrote simple class that on the start it just increase the value of
I wrote a simple code to capture the netdevice notifications and simply print their
I wrote a simple javascript function to display a progressbar with the help of
I'm trying to implement the simple-linkedinphp library (it's found at http://code.google.com/p/simple-linkedinphp/ ) It runs
Here's a sample of some oddness: #!/usr/bin/ruby require 'rubygems' require 'open-uri' require 'nokogiri' print

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.