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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.