Hi EveryOne,
I am trying to read the values entered in the form in the code below,
using python code.
And i am not able to do so.
Enter the values in the form > Click on "Submit" Display the
Information in the same page below. Further to that, insert those
values in DB, process the further as required.
This is the first time I am actually developing the page with WSGI enabled.
Next step will be creating a template HTML file instead of going on
and on and on ... with   :P
Also NOT interested with CGI / frameworks.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
THIS is the ApAcHe ERROR Log
[Sun Apr 24 21:23:08 2011] [error] [client 192.168.1.21] mod_wsgi
(pid=1664): Exception occurred processing WSGI script
'D:/wsgi-scripts/index.py'.
[Sun Apr 24 21:23:08 2011] [error] [client 192.168.1.21] Traceback
(most recent call last):
[Sun Apr 24 21:23:08 2011] [error] [client 192.168.1.21] File
"D:/wsgi-scripts/index.py", line 51, in application
[Sun Apr 24 21:23:08 2011] [error] [client 192.168.1.21] return
handler.do(environ, start_response)
[Sun Apr 24 21:23:08 2011] [error] [client 192.168.1.21] File
"D:/wsgi-scripts/index.py", line 30, in do
[Sun Apr 24 21:23:08 2011] [error] [client 192.168.1.21] name =
str(html[name])
[Sun Apr 24 21:23:08 2011] [error] [client 192.168.1.21]
UnboundLocalError: local variable 'name' referenced before assignment
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
THE FOLLOWING IS THE CODE written in
index.py
--------------
#!/usr/bin/env python
import os, re, sys
from datetime import datetime
from pymongo import Connection
class Patient:
def do(self, environ, start_response):
#uri = environ['REQUEST_URI']
html = "<html><head><title>C Informatics</title></head><body>"
html += "<h1><center>Hospital Management & Information
System</h1></center><br>"
html += '<p><br>'
# html += '<p><br>'
# html += '<p><br>'
# html += '<center>
html += '<h3>Patient Details</h3>'
html += '<form method="post">'
html += '  Patient Name
  :    <input type="text" name="name">'
html += '          Sex :
   <input =type="text" name="sex"><br>'
html += '   Age     :
    <input type="text" name="age">'
html += '    Date Of Birth    :
   <input =type="text" name="dob"><br>'
html += '   H.No.     :
    <input type="text" name="add1"><br>'
html += '   Locality      :
    <input type="text" name="locality"><br>'
html += '   City      :
    <input type="text" name="city"><br>'
html += '   PIN Code    :
    <input type="text" name="pin"><br>'
html += '   Mobile No. :     <input
type="text" name="mobile1"><br>'
html += '<input type="submit" Value="Submit">'
html += '</form>'
# html += '</center>'
## I am trying to print on screen the data entered in FORM above.
## IF I disable these lines, this page works, including the DB
connectivity, when enabled.
name = str(html[name])
# html += str(name.name)
html += "</body></html>"
# connection = Connection('192.168.1.21', 27017)
# db = connection.health
# tc = db.testColl
# item = tc.find_one({"name_first" :"PANKAJ","pid": 10008991})
# html += str(item)
# print name
# html += str(name)
output = html
mimeType = "text/html"
status = "200 OK"
response_headers = [("Content-type", mimeType),
("Content-length", str(len(output)))]
start_response(status, response_headers)
return [output]
# wsgi entry point
def application(environ, start_response):
handler = Patient()
return handler.do(environ, start_response)
--
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/modwsgi?hl=en.