HTML and CSS Reference
In this section you'll create, in four steps, a static file and serve it with Node:
• Step 1: Create a static file.
• Step 2: Load a file from a disk.
• Step 3: Send the file to the browser.
• Step 4: Run the application.
The end result will look identical to what you achieved in the previous section, but the ar-
chitecture will be improved because your display rendering is separated from your applic-
Step 1: Create a static file
The next listing is a simple index.html file—place it in a new working directory.
Listing E.2. A static index.html file
<title> Hello </title>
Step 2: Load a file from a disk
Now that you have a static HTML file, you need to load it from a disk. Node has a built-in
module for reading files from a disk called fs . You can use the fs.readFile() method
to load a file. Create a new app.js file in your working directory and add the code from the