LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-30-2010, 07:33 PM   #1
IdealVithVodka
Member
 
Registered: Apr 2010
Posts: 32

Rep: Reputation: 15
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
 
Old 08-30-2010, 08:48 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
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
 
Old 08-30-2010, 09:00 PM   #3
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by kbp View Post
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.
 
Old 08-30-2010, 09:03 PM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
To the OP: have a look at http://www.webmin.com/ - maybe it'll suffice to write a module for it.
 
Old 08-30-2010, 11:31 PM   #5
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
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.
 
Old 08-31-2010, 12:21 AM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by kbp View Post
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.
 
Old 08-31-2010, 12:43 AM   #7
14moose
Member
 
Registered: May 2010
Posts: 83

Rep: Reputation: Disabled
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!
 
Old 08-31-2010, 08:04 AM   #8
IdealVithVodka
Member
 
Registered: Apr 2010
Posts: 32

Original Poster
Rep: Reputation: 15
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
 
Old 08-31-2010, 06:50 PM   #9
IdealVithVodka
Member
 
Registered: Apr 2010
Posts: 32

Original Poster
Rep: Reputation: 15
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.
 
Old 08-31-2010, 07:04 PM   #10
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
Quote:
Originally Posted by IdealVithVodka View Post
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
 
Old 08-31-2010, 07:14 PM   #11
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
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
 
Old 08-31-2010, 07:17 PM   #12
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by exvor View Post
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.
 
Old 08-31-2010, 07:38 PM   #13
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
Old 09-01-2010, 05:50 AM   #14
IdealVithVodka
Member
 
Registered: Apr 2010
Posts: 32

Original Poster
Rep: Reputation: 15
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.
 
Old 09-01-2010, 08:10 AM   #15
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
creating a web server in linux jaepi Linux - Server 11 06-01-2007 12:20 AM
FC6 - Creating web links on Desktop trevor4706 Fedora 2 11-10-2006 09:54 PM
Creating a Web Server out of SuSE 9.1 Tuul SUSE / openSUSE 2 01-25-2005 09:12 AM
Creating a Web Page lxandrthegr8 Linux - Software 2 08-12-2003 07:29 PM
Creating Web sites ?? cruse Linux - General 1 01-20-2001 10:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration