choosing web language/technology

I would want to create a simple (but interactive) webpage hosted on the Yun.
This area is pretty new for me (I have a C++ background - nothing to do with web apps, or gui).
Typically with some keywords and google, I can get started.

What are the options on the Yun to host a webpage (i.e. what packages are abvious choices).

I guess I can do a php project. But then I have also heard of NodeJS. Any other alternatives?
Can it be done in Python, since all my other code is Python already?

What would you choose?

A to Z

These languages aren't all suited for Web development and some web development languages aren't mentioned like nodes, django, ....

Django is a high-level Python Web framework.
Node.js is a platform built on Chrome's JavaScript runtime.

Both are supported well at Yun.

Yun supports Apache, Lighttpd, nginx, uhttpd... as web server.

Some of them support CGI (Common Gateway Interface), CGI allows A to Z support at web develop.

We could use MIPS Assembly Language coding web page technically.

NewLine:
These languages aren't all suited for Web development and some web development languages aren't mentioned like nodes, django, ....

NewLIne,
you've defined a large target. Could you cite some examples of what you would like to do? Interactive is a broad statement. Do you want "push button/reload page"? or "click and respond"? or a "page that updates with clicking"?

Please don't cite examples behind "walled gardens", like AOL or Facebook.

My guess is you'd like something like AJAX

Let us know.
Jesse

Depending on what you are really wanting to do, there would be plenty of options for you, I'm sure.

One thing I have done is to move away from using the large and bloated LAMP stack in favour of coding up my own server, which is based upon a standard C library libmicrohttpd.

If you program in C/C++ you will find this a nice and very lightweight HTTP server that can be set to operate as a daemon.

Now, I don't use a YÚN, but rather a Cubieboard connected to an Arduino, so I guess a simialr setup, but with much more capability.

Anyhow, if you are interested in SCADA using clean code web apps as GUI, you can read more at my signature at the section Quadlog to get more of an idea.

Again, if you're interested, it uses SQLite and Modbus libraries as well as part of the implementation.


Paul

Thanks all for the answers and suggestions…one of the problems though is that the choice is overwhelming, and I cant investigate everything, especially since I am quite noobish at web programming. But I will definitely read a bit about the terms you mentioned.

jessemonroy650:
NewLIne,
you’ve defined a large target. Could you cite some examples of what you would like to do? Interactive is a broad statement. Do you want “push button/reload page”? or “click and respond”? or a “page that updates with clicking”?

I currently have an existing Yun project. The code I wrote for the linux side is 100% Python.
The application is something to control the temperature of a fermentation.
Currently I control the python parameters (e.g. temperature, directories, …) via mail. I.e. the python side checks for email every minute, and parses an xml file embedded in the mail. The logging of temperature, heating on/off, etc… are uploaded to an external site using ftp.

The ftp side is ok, but the control via mail isn’t very user friendly. So I want to try to make it more user friendly using a web based control. So my webpage would contain:

  • several fields to enter for example the temperature I want to regulate everything to
  • a button, that when clicked would make these values available to my existing python script.
  • a field that displays the current temperature (gets it value from the python script in some way)

I think that is pretty basic stuff…

NewLine:
::::

The ftp side is ok, but the control via mail isn’t very user friendly. So I want to try to make it more user friendly using a web based control. So my webpage would contain:

  • several fields to enter for example the temperature I want to regulate everything to
  • a button, that when clicked would make these values available to my existing python script.
  • a field that displays the current temperature (gets it value from the python script in some way)

I think that is pretty basic stuff…

Okay,
for most of what you ask, you can use a basic form. Standard, run-of-the-mill .
The first two (of three) items can be handled with the standard webserver, a form, and a CGI (which you can build in python). The field that displays the current temperature can be done with a CGI, and one AJAX call. The Ajax call will be the most complicated, but not difficult. There are plenty of examples in the wild.

You don’t need ANY framework. If you can write a form in HTML, it can be done. If you need help with the AJAX, I’d be happy to help. Make the work easy.

However, if you’d like to learn a framework, don’t let me stop you. I recommend web2py. If you want a job from this I recommend django. If you want the latest (the du jour, the hotness), then node.js, websockets, jquery, & react.js

Hope this helps.
Jesse

Thanks, good suggestions. Maybe not a bad idea to keep it simple...

If I were to use cgi to call a script, what would be a correct way of letting this script communicate to my main Python script?

A simple way would be to use files, but I am not sure if this could cause a mess if both processes want to access it at the same time?

NewLine:
Thanks, good suggestions. Maybe not a bad idea to keep it simple...

If I were to use cgi to call a script, what would be a correct way of letting this script communicate to my main Python script?

A simple way would be to use files, but I am not sure if this could cause a mess if both processes want to access it at the same time?

NewLine,
You could use a socket on the Linux side, but that might be to tedious. One solution would be to keep an active state record, perhaps in the mailbox or in a file. If you are worried about "race conditions", then a standard practice is to maintain a "lock" file (SEE: 7.10.2. Locking). This has hazards, of course.

Another solution is to use a "swap record". With this method you never write to the "active state". You

  • Write to "swap record" (current state)
  • Remove the active state
  • Replace the active state with the "swap record" (current state)

The benefit of this, is that in the worst case the program reading the "active state" would get a partial record or a "NULL" (or file not found). In which case the error is known and recovery can proceed to a known state (either wait, give up, or retry). It has hazards as well.

Let me know if this helps.
Jesse

I'll look a bit more into the swapfile method. I was actually looking into using Queues for the communication.

I just wanted to give an update what I finally choose as solution:

I choose 'bottle' to run the webserver. I choose it mainly because it is easy to integrate with the rest of my Python stuff and because I liked that everything is in a single file.

I am using threading.Lock and Queue's to communicate between the bottle webserver and my main script.