Hi All,
I am new to Python. I am not able to get the python script run in the browser. I am using IIS as my webserver and my python version is Python-2.4. I am under Windows-XP OS. I have done one my directories to be a virtual directory to run in my web browser. I have written some sample codes as follows
- form.html
This is a simple HTML form from where I am posting the data to a python file. The python code as below:
- process_form.py
When I am trying to run in the browser it show me the form but aftre entering the data in the form field and submitting it just shows up the python code in the next page like below:
#!c:\Python24\p ython.exe import cgi form = cgi.FieldStorag e() # instantiate only once! name = form.getfirst(' name', 'empty') # Avoid script injection escaping the user input name = cgi.escape(name ) print """\ Content-Type: text/html\n
The submitted name was "%s"
""" % name
So please suggest me what I need to do to execute a python code from a browser what is the mistake I have done here?
Thanks and Regards,
Chittarajan :)
I am new to Python. I am not able to get the python script run in the browser. I am using IIS as my webserver and my python version is Python-2.4. I am under Windows-XP OS. I have done one my directories to be a virtual directory to run in my web browser. I have written some sample codes as follows
- form.html
Code:
<html><body> <form method="get" action="process_form.py"> Name: <input type="text" name="name"> <input type="submit" value="Submit"> </form> </body></html>
- process_form.py
Code:
#!c:\Python24\python.exe import cgi form = cgi.FieldStorage() # instantiate only once! name = form.getfirst('name', 'empty') # Avoid script injection escaping the user input name = cgi.escape(name) print """\ Content-Type: text/html\n <html><body> <p>The submitted name was "%s"</p> </body></html> """ % name
#!c:\Python24\p ython.exe import cgi form = cgi.FieldStorag e() # instantiate only once! name = form.getfirst(' name', 'empty') # Avoid script injection escaping the user input name = cgi.escape(name ) print """\ Content-Type: text/html\n
The submitted name was "%s"
""" % name
So please suggest me what I need to do to execute a python code from a browser what is the mistake I have done here?
Thanks and Regards,
Chittarajan :)
Comment