Creating a Simple File Server
We will first create a simple file server to serve the front-end of our application. To do this we will make use of the Express Framework. Express is a (self-described) fast, unopinionated, minimalist web framework for Node.js.
Begin by opening server.js and adding the require statement for express right below the existing require statement for the paths:
Next, we will add code to serve the static files contained in the tutorial:
As of the time of this writing, the first line of code is necessary to address an issue in Express with serving Web Assembly files. The rest configures the express server to use the public directory as a root directory for serving static files on port 8081.
We can test the file server is working correctly by running the following command in the terminal:npm start
After running the command navigate to http://localhost:8081 in your browser of choice. You should see a page with a button and a dropdown menu, which will eventually be used for spawning viewers.