Some give some ideas here please.

Thanks

On 17 October 2014 16:54, nitin chandra <[email protected]> wrote:
> Looking for a solution I posted 2 queries, Patrick, I am therefore
> replying to one thread and including you in the mail list.
>
> All lines are with proper indentation. Individually each page loads
> and works. Not as a web solution.
> Index.py & insertDB.py file are below
>
> Thanks
>
> index.py file
> -----------------------------
> #!/usr/bin/env python
>
> import os, re, sys
> import datetime, cgi, cgitb
>
> class Handler:
>      def do(self, environ, start_response):
> form = cgi.FieldStorage(fp=environ['wsgi.input'],
> environ=environ)
>
> html = """
>          <html><head><title>Project Name</title>
>
> html += '<form method="post" action="insertDB.py">'
>
> ## insertDB does is Display the value collected from form in a new web
> page and at the same time inserts the data in PostgreSQL DB.
>
> today = datetime.date.today().strftime("%d/%m/%Y")
> day = datetime.date.today().strftime("%A")
> curr_time = datetime.datetime.now().strftime("%H:%M:%S")
>
> html += '<td align="right">Date:<input readonly type="text" size="12"
> name="TodayDate" value="'+ str(today) +'">'
> html += 'Time :<input readonly type="text" size="12" name="curr_time"
> value="' + str(curr_time) + '"></td></tr>'
> html += '<td align="right">Day :<input readonly type="text" size="8"
> name="day" value="'+ str(day) + '"></td></tr>'
>
> html += '<tr><td align=right><input type="submit" Value="Submit"></td></tr>'
> html += '</form>'
> html += """
>          </center>
>
>          </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)
> ========================================================
>
> insertDB.py
> ------------------
>
> #!/usr/bin/env python
>
> import os, sys
> import cgi, urllib2, cgitb
> #import psycopg2
>
> class Handler:
> def do(self, environ, start_response, **kwargs):
> form = cgi.FieldStorage(fp=environ['wsgi.input'],
> environ=environ)
>
> TodayDate = form.getvalue('TodayDate','ERROR').lower()
> curr_time = form.getvalue('curr_time','ERROR').lower()
> day = form.getvalue('day','ERROR').lower()
>
> html += '<tr><td><b>Todays\' Date :</b></td><td><input type="hidden"
> name="TodayDate" value="'+ str(TodayDate) + '"><b>' + str(TodayDate) +
> '</b></td><tr>'
> html += '<tr><td><b>Time :</b></td><td><input type="hidden"
> name="curr_time" value="'+ str(curr_time) + '"><b>' + str(curr_time) +
> '</b></td><tr>'
> html += '<tr><td><b>Week Day :</b></td><td><input type="hidden"
> name="day" value="'+ str(day) + '"><b>' + str(day) + '</b></td><tr>'
>
>      #    connection = Connection('localhost', 5432)
> ### Let this work, then I shall complete the DB connection and insertion.
>
> 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)
>
>
>
> On 17 October 2014 12:02, Roberto De Ioris <[email protected]> wrote:
>>
>>> I dont know how to get value from a web form using ONLY WSGI,
>>
>>
>> If you mean data sent via POST, you need to read the environ['wsgi.input']
>> file-like object and parse its content
>>
>>
>>
>> --
>> Roberto De Ioris
>> http://unbit.it
>> _______________________________________________
>> uWSGI mailing list
>> [email protected]
>> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to