[webmin-devel] ajax with webmin

Krause Felix <[email protected]> Tue, 23 Jul 2013 06:57:43 +0000
Newsgroups gmane.comp.web.webmin.devel
Message-ID <01E5320FA68E4D4E94C059320E4D29460DD9C623@svcstexbal05.devoteam.com>
Hi everyone,

I am implementing a webmin module for monitoring an embedded system. The webmin installation is primarily used to administrate the OS, but should also be able to show the current status of the main application running on it. I need to use AJAX to automatically update the visualization of some I/O channels.

Now the application has a RESTful, JSON-based interface for accessing its status. The problem is that it does not do any authentication, so it is reachable only from localhost for security reasons. My Webmin module retrieves information from there and renders it. For the AJAX requests, the Webmin module should act like a proxy and just pipe through the content retrieved from the application. I tried the following in a script io.cgi as part of my Webmin module:

my $client  = HTTP::Client->new();
my $content = $client->get("http://127.0.0.1:8888/io");

print "HTTP/1.1 200 OK$CRLF";
print "Content-Type: text/json$CRLF";
print "Content-Length: " + length($content);
print "$CRLF$CRLF$content";

This does not work; when I try to retrieve /myModule/io.cgi, I get:

HTTP/1.0 500 Bad Header
Server: MiniServ/1.620
Date: Tue, 23 Jul 2013 06:07:06 GMT
Content-type: text/html; Charset=iso-8859-1
Connection: close

Is it possible to do this with Webmin?

Regards,
Felix

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
-
Forwarded by the Webmin development list at [email protected]
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel