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
Expand|Select|Wrap|Line Numbers
- <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
Expand|Select|Wrap|Line Numbers
- #!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\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
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 :)