LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   creating a web ui (https://www.linuxquestions.org/questions/programming-9/creating-a-web-ui-829410/)

IdealVithVodka 08-30-2010 07:33 PM

creating a web ui
 
Hi everyone,


I'm not if this is the best section to ask the question. If so please move it.


I'm trying to create a web user interface for a network device. The target can be a router or a switch. Its for education purpose. I'm asking as maybe some of You know if there any libraries or available frameworks that would make it much easier for me to create a web ui. I would like to be able to create for instance a DHCP configuration page for the user and that whatever modification he makes and presses the save button then it will get stored in udhcpd.conf file (for example). Would You recommend any programing language for this task ?


Thank You in advance


With Kind Regards
IdealWithVodka

kbp 08-30-2010 08:48 PM

I'm sure there are thousands that would disagree but I usually use perl, it's supported on most platforms, fairly light on resources and it's flexible.

my2c

Sergei Steshenko 08-30-2010 09:00 PM

Quote:

Originally Posted by kbp (Post 4083015)
I'm sure there are thousands that would disagree but I usually use perl, it's supported on most platforms, fairly light on resources and it's flexible.

my2c

How does one create a WEB GUI with Perl ? I mean, I think WEB GUI means a GUI running in a browser.
...
The OP first of all needs a WEB server running, and that server has to generate static or dynamic WEB pages, and the WEB pages will be displayed by the browser, and depending on user's actions the commands will be sent back to the server, and the server will control the device based on the info derived from the user's actions.

Sergei Steshenko 08-30-2010 09:03 PM

To the OP: have a look at http://www.webmin.com/ - maybe it'll suffice to write a module for it.

kbp 08-30-2010 11:31 PM

I meant as a .cgi ... assuming that there is a web server present. You can implement a simple webserver using perl but it's not ideal.

Sergei Steshenko 08-31-2010 12:21 AM

Quote:

Originally Posted by kbp (Post 4083097)
I meant as a .cgi ... assuming that there is a web server present. You can implement a simple webserver using perl but it's not ideal.

No problem with that.

14moose 08-31-2010 12:43 AM

Hi -

I would definitely recommend simple HTML and CSS for the GUI, and probably Perl for the back-end (CGI).

For whatever it's worth, OpenWRT uses Lua for their "CGI". As you're possibly aware, OpenWRT has a lot of similarities with your project.

And OpenWRT uses "LuCI" for their Web UI - a LUA-based web framework that might be exactly what you're looking for:

http://luci.subsignal.org/

'Hope that helps!

IdealVithVodka 08-31-2010 08:04 AM

Thank You getns for the reply.

And yes, I'm planning to run the web ui in collaboration with a web server. While I have checked some of the link you have provided I've found something on my own. Its called UKI and can be found here

http://ukijs.org/

And I think that this is the thing I was looking for. Well, I will need to design everything on my own (in terms of page layout etc etc), but it seems to be very helpful. What do You think?

I will try to make a simple dhcp server configuration via web interface and post some outputs / results


Thanks again

IdealVithVodka 08-31-2010 06:50 PM

Regarding my project, I'm having a problem of saving any changes to the hard disk of the "router". Apparently its not possible to perform any writes to the disk via javascript. For now I would like to be able to save any data (can be "Hello world!") to a file on the router side (where the web ui is running on a httpd). Any ideas how to perform that ? As I can gather the information from the text boxes with javascript, but it would be nice if I could save that data to a config file on the router.

frieza 08-31-2010 07:04 PM

Quote:

Originally Posted by IdealVithVodka (Post 4084129)
Regarding my project, I'm having a problem of saving any changes to the hard disk of the "router". Apparently its not possible to perform any writes to the disk via javascript. For now I would like to be able to save any data (can be "Hello world!") to a file on the router side (where the web ui is running on a httpd). Any ideas how to perform that ? As I can gather the information from the text boxes with javascript, but it would be nice if I could save that data to a config file on the router.

write to the webserver using a client side programming language? nope not gonna happen, you need a server side language like php or perl or a c++ program cross compiled for the device to do that, provided the webserver can handle that

exvor 08-31-2010 07:14 PM

If its a router or something it probably has very limited processing capabilities so like the poster above I would say C or C++.







Ohh and here is something for the poster above. :)

0100111001101111001000000100011101101110011011110110110101100101011100110010000001100001011100100110 0101001000000110011001101111011100100010000001101011011010010110001101101011011010010110111001100111 00100001

Sergei Steshenko 08-31-2010 07:17 PM

Quote:

Originally Posted by exvor (Post 4084146)
If its a router or something it probably has very limited processing capabilities so like the poster above I would say C or C++.
...

Someone has already mentioned 'lua' - it's pretty lightweight.

theNbomr 08-31-2010 07:38 PM

Can you please clarify for us all (well, for me, at least): on what part of the web connection is the 'router' running? The browser end, or the web server end? It sounds like you are trying to create a web interface for configuring some sort of device, but trying to do the whole thing with a browser. If you are trying to create a UI as a way of configuring a hardware device, then you want to be writing a HTTP server, to which the user connects with a web browser. A primitive HTTP server can be created in a couple of hundred lines of C code, probably less.

--- rod.

IdealVithVodka 09-01-2010 05:50 AM

Thank for the replies gents.

I wants to be able to save the data provided by the user to a file on the router (for example dhcp details like lease time, address range etc). Like frieza already mentioned I need a server side programing language. So would I need a modified httpd web server that could handle some additional calls ? So when he would get one he would execute a hard coded action on the router side (is that correct?). So how do the normal routers (real ones : netgear, linksys etc) deal with this as you can configure everything via a web interface.

@theNbomr :

On the router I want a webserver (httpd for example) that will have available a web user interface to configure the device.

theNbomr 09-01-2010 08:10 AM

Okay, so is the router a dedicated Linux host to which you have access to the internal workings? Or, is it a closed box that contains all of the functionality of a router? If the latter, then I don't see a way of accomplishing what you want.
If the former, then you should be able to create a CGI that can present, update, & store configuration data for the router function. You will probably need to modify some permissions, create filesystem links, etc. to allow the web server process/UID to access the configuration files. You could use an existing HTTP server such as Apache for this purpose. A CGI running under the HTTP server could receive user configuration data, store it in the accordant file(s), and perform whatever daemon restarts are necessary to use the new data.
CGI applications can be written in most any language, but there are a few that are much more commonly used, such as Perl. The CGI needs to be able to access HTTP form data from either GET or POST HTTP requests, which is done by reading commandline data or stdin, respectively. The data is processed according to the requirements of the application, and then probably stored in appropriate data files. In this application, it would probably be necessary to invoke server-side scripts to coerce the related processes to reload using the updated configuration data. Perl, among other languages, has some modules that make most of this quite streamlined. Certainly the CGI module would be one that is very commonly used in such cases. It will aid you in acquiring the HTTP form data, as well as creating HTML response pages for the UI.
If I have understood your requirements correctly, all of this should be fairly straightforward.
--- rod.


All times are GMT -5. The time now is 01:46 PM.