Let's build an endpoint that will retrieve the block-explorer file for us:
- Go to the dev/networkNode.js file, and in here, create a new endpoint that will send this file to us. Define the endpoint as follows:
app.get('/block-explorer', function(req, res) {});
- Now, inside of this endpoint, all we want to do is send back the index.html file to whoever called this endpoint:
app.get('/block-explorer', function(req, res) { res.sendFile('./block-explorer/index.html', { root: __dirname });});
You must have observed in the previous sections that we usually use res.json, which is a way to send JSON data. However, in this endpoint, we want to send the whole file, so we'll use the res.sendFile method instead. ...