I was looking to create a simple Upload application for the Raspberry pi. I am a fan of IOT, and I am currently a computer science student. The raspberry pi zero, and pi 1 have different processors than the raspberry pi 2 and pi 3. (ARM6 vs ARM7).
I needed a way for this "web application" to run on any version of raspberry pi. I decided to use NodeJs for various reasons. Node can be run on multiple threads with pm2, NodeJs is faster than php, and NodeJs is the fastest growing language of all time. Raspbian OS has node already installed when you flash the image to your pi. However, it is not the most current version of NodeJS, so here is a shell script I made to install the latest version of Node. I made the script as easy as: copy/paste the README.md code block into your pi terminal: NodeJs-Raspberry-Pi
If you are new to node, then get ready for a wild ride, and I don't mean a bad ride. Node has many different ways you can start a web server:
- You can run your web server from the HTTP library (i don't exactly recommend this).
- You can use the Express Library.
- You can use the Hapi.js Library.
- You can find another library.
- The best way to find libraries is to visit npm and search for something you find interesting.
- You will eventually use npm to build your application from other people's built modules.
- I highly recommend that if you are fairly new to node that you build simple applications by combining two different modules that already exist.
- When designing an application it also helps to watch others code. My favorite youtube channel is here, which I watch every week on Monday. Check out higher order functions, maps, and reduce
I found that the best browser tabs to have open while building NodeJs applications is the:
and also these, because I used them the most:
I contacted lifeHacker.com because all the coder kids hang out there. They publish the Instructables the next day, and Dataplicity published the project on their announcement page a day or two after lifeHacker. I can't stop learning NodeJs. It's so powerful, and there are so many wonderful application that are being built at an amazing pace. What seperates NodeJs from the rest is not only is it fast, but your dependencies are installed recursively. So when you install a dependency, if that dependency has dependencies, then your node package manager (npm) will install those dependencies, and if those dependencies have dependencies then they will be installed also, and etc...