kib schrieb:
Diez B. Roggisch a écrit :
Tool69 schrieb:
Hi,
Until now, I was running my own static site with Python, but I'm in
need of dynamism.
After reading some cgi tutorials, I saw Joe Gregorio's old article
"Why so many Python web frameworks?" about wsgi apps [http://
bitworking.org/news/Why_so_many_Python_web_frameworks] and have a
question about it. The code he gave works like a charm (I had to make
a little change because SQLAlchemy has changed since), but how the
hell can I serve static files (css, js, images, etc.) within an wsgi
app, ie inside a '/static' directory ?!
There is a wsgi-app out there that is called "static". Use that.
And it's the first hit on google "wsgi static"... :)
http://lukearno.com/projects/static/
Diez
Hi Diez,
and thanks for yout help. In fact I already found it but never managed
to get it work because the static doc says :
from wsgiref.simple_server import make_server
import static
make_server('localhost', 9999, static.Cling('/var/www')).serve_forever()
and inside J.Gregorio's tutorial it is:
from wsgiref.simple_server import WSGIServer, WSGIRequestHandler
httpd = WSGIServer(('localhost', 8080), WSGIRequestHandler)
httpd.set_app(urls.urls)
It does not use 'make_server()' so how can I adapt it ?
static.Cling is a wsgi-app. The other code just makes a specific
wsgi-implementation based server out of it.
I finally managed to work with static files with a little hack, but it's
ugly because I'm reading each static file per request.
How else should that work? Apache does that the same way.
Diez
--
http://mail.python.org/mailman/listinfo/python-list