O'Reilly logo

Programming the BeagleBone by Yogesh Chavan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Program for creating new Node.js HTTP server

To control BeagleBone from the Internet we need to run an HTTP server on it. BeagleBone already has Node.js running as the HTTP server to be able to run Cloud9 on port 3000. There are built-in Node.js HTTP interfaces that can be used to create a new HTTP server on a specified port number. Once created, this server listens to HTML queries on the specified port. On request, it sends an HTML file to the client. The client browser renders this HTML file. So, we have to write JavaScript code to run the Node.js HTTP server and write an HTML file to be displayed. Let's create a HTML file first.

HTML code

Open Cloud9 IDE and open a new file tab. Write the following code in it and save it as iot.html.

The code ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required