alikob
Posts: 3
Joined: Wed Jun 17, 2015 6:58 pm
Location: Alpharetta,GA

Web Server code on RPi

Wed Aug 17, 2016 12:15 am

I have a mini project to control a shade wirelessly. Its main components is a RPi as a master controller, in addition to a nRF24LE1 (wireless chip by Nordic ) as a slave. I have already finished the firmware to send a cmd from RPi to nRF24LE1 using console. Now I am planning to use a web based application running on Pi, (I am using NGINX for now), for sending the command. I have no experience in web server programming or any php/cgi scripting language, Here it comes my question??? The firmware running on Pi is a continuous loop, has to be running all the time like a daemon or background code, and when it receives an input like “UP” or “DN” it should send a cmd to slave. Any idea how to implement the web server part? Is NGINX ok, or use something else like Apache or even LightHTTpd? How about php or html code? And lastly how to manage the cgi executable code to act like a daemon running continuous in the background? My main master code in RPi is written in C++, Not Perl Nor Python! Thanks for any help!

mfa298
Posts: 1387
Joined: Tue Apr 22, 2014 11:18 am

Re: Web Server code on RPi

Wed Aug 17, 2016 11:56 am

You can write CGI/web apps in any language however:

php has a lot of documentation on how to set it up and write basic applications, some of this documentation is good but there's also a lot of bad or incomplete examples out there as well.

python and ruby can run embedded web servers (so no need for apache/nginx etc) and can also interface directly with the gpio or can call console applications relatively easily.

As for the best choice I'd partly suggest stick with what you know. However cgi in C++ is probably the hardest option so using something else (python/ruby/php/perl) may be a better choice.

Return to “Beginners”