Step 2 – Create the backend Python code

Now, let's see the back end Python code ( that will accept these inputs from HTML form and perform its task. The code is as follows:

#!/usr/bin/env pythonimport cgiimport paramikoimport timeimport reimport sysimport osimport requestsimport urllibimport datetimefrom datetime import datetimefrom threading import Threadfrom random import randrangeform = cgi.FieldStorage()searchterm = form.getvalue('searchbox')cmds = form.getvalue('cmds')changeid = form.getvalue('changeid')prepost=form.getvalue('prepost')searchterm=searchterm.split(",")xval="""%Y-%m-%d_%H_%M_%S")returns = {}def getoutput(devip,cmd):    try:        output=""        mpath="C:/iistest/logs/" fname=changeid+"_"+devip+"_"+prepost+"_"+xval+".txt" ...

Get Python Network Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.