1

I am trying python with CGI for web interface development. Clicking on a button on webpage should call function to get clock details from network device.

import sys, os    
#importing library files
sh_clk = ""

class test_001(test_case):   
    def setUp(self):
        #Establish a telnet session to the network device.

    def tearDown(self):
        # Close the telnet session 

    def test_001(self):
        global sh_clk
        sh_clk = device("show clock")

if __name__ == '__main__':

    print "Content-type:text/html\r\n\r\n"
    print '<html>'
    print '<head>'
    print '<title>First CGI Program</title>'
    print '</head>'
    print '<body>'
    #run_test
    print '<h2>'+sh_clk+'</h2><br>'
    print '</body>'
    print '</html>'

With above code, following output got printed on webpage.

Mon Oct 21 2013 17:50:06 UTC

I want to create one button "show clock", clicking on it, should display time. Couldn't figure out how to achieve this, below is the raw code with missing function calls.

print '<form>'
print '<input type="button" value="Open Window" onclick="something missing">'
print '</form>'
print '<h2><div id="sh_clk"></div></h2>'
print '<button onclick="something missing">Show Clock</button>'

It will be of real help if some one can suggest how to fulfill the requirement.

4

0 回答 0