gert schrieb:
I would like to read the following from a text file
Hi gert,

I'm puzzled, what is wrong with using wsgi as advertised? Just import your code and insert it in the wsgi chain no?

cheers
 Paul


from json import loads
from gert.db import Db
def application(environ, response):
    v = loads(environ['wsgi.input'].read(int(environ
['CONTENT_LENGTH'])).decode('utf-8'))
    db = Db()
    db.execute('UPDATE votes SET count=count+1 WHERE vid=?',(v
['vid'],))
    db.execute('SELECT * FROM votes')
    j = '{"rec":'+db.json()+',\n'
    j+= ' "des":'+db.jdes()+'}'
    j = j.encode('utf-8')
    response('200 OK', [('Content-type', 'text/
javascript;charset=utf-8'), ('Content-Length', str(len(j)))])
    return [j]

execute it, and wrap a new function name around it for example

def wrapper(environ, response):
     exec(file)
     return application(environ, response)

How do I do this in python3?
--
http://mail.python.org/mailman/listinfo/python-list


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to