What is the simplest way to serve static files with WSGI and Python 3.2? There are some WSGI apps for PEP 333 and Python 2 for this purpose - but was is about PEP 3333 and Python 3? I want to use wsgiref for development.
问题:
回答1:
Typically, you don't want to serve static files using WSGI. WSGI is used so that dynamic content can be generated by using Python. Static files, by definition, are not dynamic content, so you don't need the additional layer of WSGI and any web app you've built on it. Instead, you would be best to set up your web server (apache, nginx, iis, etc.) to serve the static files separately, alongside your WSGI application.
Edit: Interestingly, I JUST found myself in this spot after you clarified your issue. Here's something I found that you might appreciate. It's called "static".
http://lukearno.com/projects/static/
https://bitbucket.org/luke/static/
回答2:
Bottle supports PEP 3333, serving static files and is very small. It might fit the bill for you. I agree with Mark Hildreth's answer, but if you need static serving for development and to work with Python 3, Bottle is a good bet. Note: Bottle uses 2to3.
回答3:
Here are several links to information on WSGI apps for Python 3.
Custom: https://bitbucket.org/mitsuhiko/wsgi3k/ modwsgi: http://code.google.com/p/modwsgi/wiki/SupportForPython3X CherryPy: http://www.cherrypy.org/wiki/WSGI specifically the WSGI 1.0 vs. WSGI 1.1 section.
All those links come from this page:
http://www.wsgi.org/wsgi/Python_3
It looks to me like the most mature one at this point is CherryPy. I am also sure that CherryPy provides an easy way to serve static files.