You can't use a relative path name for index.py as the current working directory is not where your code file resides. See:
http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Application_Working_Directory Graham On 7 June 2011 15:19, nitin chandra <[email protected]> wrote: > Thank you Graham, list, > > I tried the tutorial, but I really need to work thing this way ... pl > I really need to, I am so close, but painfully am not able to take it > further. > > I tried with the following changes in 'response.py' > > doc = lxml.html.parser('index.py') . > The error in apache logs was, index.py - File does not exist. > > form = doc.form[0] > > A solution with lxml.html will be greatly appreciated. > > TIA > > Nitin > > >> If you really must use low level WSGI there is a tutorial at: >> >> http://webpython.codepoint.net/wsgi_tutorial >> >> Try first the examples in there about forms handling with cgi module. >> When you understand those, adapt your example to suit. >> >> Graham >> > >>> ============================= >>> index.py >>> ------------- >>> >>> #!/usr/bin/env python >>> >>> import os, re, sys >>> >>> class Handler: >>> 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><br>" >>> html += '<p><br>' >>> html += '<p><br>' >>> html += '<p><br>' >>> html += '<center>' >>> html += '<form method="post" action="response.py">' >>> html += 'User Name :<input type="text" name="name"><br>' >>> html += 'Password   :<input type="password" >>> name="paswd1"><br>' >>> html += '<table>' >>> html += '<TR/><TD NOWRAP/>Highest Qualifications:' >>> html += '<TD/><SELECT name="hiqual"/>' >>> html += '<OPTION/>Ph.D / Doctorate' >>> html += '<OPTION/>Post Graduation' >>> html += '<OPTION/>Post Graduation Diploma' >>> html += '<OPTION SELECTED/>Graduation' >>> html += '<OPTION/>Diploma' >>> html += '<OPTION/>Undergraduate' >>> html += '</SELECT/><br>' >>> html += '<input type="submit" Value="Log In">' >>> html += '</form>' >>> html += '</center>' >>> html += "</body></html>" >>> 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 = Handler() >>> return handler.do(environ, start_response) >>> >>> ============================================= >>> >>> response.py >>> ----------------- >>> >>> #!/usr/bin/env python >>> >>> import os, re, sys >>> import cgi >>> >>> class Handler: >>> def do(self, environ, start_response): >>> form = cgi.FieldStorage(fp=environ['wsgi.input'], >>> environ=environ) >>> name = form.getvalue('name') >>> paswd1 = form.getvalue('paswd1') >>> hiqual = form.getvalue('hiqual') >>> html = 'name is ' >>> html += name >>> html += ' and password is ' >>> html += paswd1 >>> html += '<br> Highest Qualification is : '+ hiqual >>> 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 = Handler() >>> 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. > > -- 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.
