Need walkthrough to allow user to enter text, run python code, return result
-
I’m a python programmer but a neophyte to php and a wysiwyg user of wordpress. I have a problem I need help with. I have a python code called text.py which does some stuff to a line of text. In reality it is some complicated natural-language processing. For now, let’s say it returns input text in all caps. I would like to make a wordpress page that has an input box where the user can enter text, click a button, and that text will be sent to the python code, the results of which will be shown back on that page underneath.
For kicks, here is a sample python code text.py:
`import sys
if __name__ == “__main__”:
print ” “.join(sys.argv[1:]).upper()>>>python text.py “hello there world”
HELLO THERE WORLD`Looking around the web, I haven’t found any comprehensive “here is what you do” from start to finish. I think this could be REALLY useful for other people trying to do similar things.
I have python running on my web server, so that part is taken care of. I could use a step by step tutorial of how to:
1. create the page with a box to enter text and a button to run the code.
2. interface to send that text to the python code and run it
3. way to print the output on the wordpress page.
The topic ‘Need walkthrough to allow user to enter text, run python code, return result’ is closed to new replies.