I have classical python server.
I made a CGI script. I would like from a click in the client side, execute a script in the server side and screen the result in the same page dynamically in the client side.
I know how to update dynamically a page in the client side but I didn’t find a way to do it from the server side.
For instance my initial webpage:
print 'Content-type: text/html'# image/svg+xml'
print '''
<html>
<head>
</head>
<body>
<h1>My PAGE</h1>
<a href=#1" onclick="launcher(arg);">Execute my program</a>
<div id="1" style="display: none;" name="resul1"></div>
</body>
</html>
'''
I would like to execute a script in the server when we click like this kind of execution:
command = "python myscriptinLocal.py -a %s"%(arg)
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process.wait()
A result file is generated in the server, and I would like to screen the result in the current page without to generated a new page….
Is it possible? Is there a way to do that with python or with another language?
You can use any one of python WSGI frameworks to do exactly that. Just sign a free account with Google App Engine and you will be able to do that immediately. Although you may not be able to spawn your own process nothing will stop you from executing your python script and output it as html!
Google app engine pages in Stack:
https://stackoverflow.com/questions/tagged/google-app-engine?sort=votes