Hi Scott,
> could some please point me in right direction or provide an example?
I'll provide you with a very basic and simple example. I hope it'll get you started!
samra.py:
-----------
import cherrypy
import os
class Samra(object):
@cherrypy.expose()
def index(self):
return """
<form method="post" action="processform">
find: <input type="text" name="find"><br>
replace: <input type="text" name="replace"><br>
<input type="submit">
"""
@cherrypy.expose()
def processform(self, find, replace):
os.system('python samrajob.py "%s" "%s"' % (find, replace))
return "done."
cherrypy.quickstart(Samra(), "/")
samrajob.py:
---------------
import sys
print "Doing the job of replacing '%s' with '%s'" % (sys.argv[1], sys.argv[2])
How to run:
-------------
1. start webapp with:
python samra.py
2. point webbrowser at
http://127.0.0.1:8080/
3. fill in some values, for example, 'hello' and 'there'
4. press Submit
Look at the console. You'll see something like:
[15/Jun/2014:18:49:37] ENGINE Serving on
http://127.0.0.1:8080
[15/Jun/2014:18:49:37] ENGINE Bus STARTED
127.0.0.1 - - [15/Jun/2014:18:49:47] "GET / HTTP/1.1" 200 215 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:29.0) Gecko/20100101 Firefox/29.0"
Doing the job of replacing 'hello' with 'there'
127.0.0.1 - - [15/Jun/2014:18:49:51] "POST /processform HTTP/1.1" 200 5 "
http://127.0.0.1:8080/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:29.0) Gecko/20100101 Firefox/29.0"
Notice that 'Doing the job of replacing 'hello' with 'there'' line? That's the evidence your working script was called from the webapp.
Greetings,