Search⌘ K

Publishing Web Pages

Explore how to publish web pages by serving HTML files and client-side assets with Express. Learn to organize your server with views and public folders, creating dynamic web content with JavaScript on both front-end and back-end.

We'll cover the following...

Finally, let’s learn how to serve HTML content so that your web server can come into its own. For example, GET HTTP requests to the "/hello" route should show a basic web page. A naive way to do so would be to simply return an HTML string.

However, things would quickly get out of hands as the complexity of the web page grows. A better solution is to define the HTML content in an external file stored in a dedicated subfolder, and return that file as a result of the request. For example, create a subfolder named views ...