eval(WsgiApplication)
gert
gert.cuykens at gmail.com
Sat May 2 05:49:20 EDT 2009
On May 2, 10:25 am, Arnaud Delobelle <arno... at googlemail.com> wrote:
> gert <gert.cuyk... at gmail.com> writes:
> > I would like to read the following from a text file
>
> > 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?
>
> What's wrong with importing it?
The problem is that my wsgi files have a wsgi extention for mod_wsgi
use
package
- __init__.py
- session.py
- db.py
- sqlite
- - sql.db
- www
- - test.htm
- - test.css
- - test.js
- - test.wsgi
i would like to make this package work both in mod_wsgi and cherrypy
server
mod_wsgi has a .wsgi handler because it is recommended to rename the
wsgi file with wsgi extensions to avoid double imports
cherrypy server has a dispatcher class
More information about the Python-list
mailing list