Serving Static Files Using WSGI and Python 3

What is the easiest way to serve static files with WSGI and Python 3.2? There are several WSGI applications for PEP 333 and Python 2 for this purpose - but was there PEP 3333 and Python 3? I want to use wsgiref for development.

+6
source share
3 answers

Generally, you do not want to serve static files using WSGI. WSGI is used to create dynamic content using Python. Static files are, by definition, not dynamic content, so you don’t need the extra WSGI layer or any web application you created on it. Instead, your best bet is to set up a web server (apache, nginx, iis, etc.) to serve static files separately with the WSGI application.

Edit: Interestingly, I ONLY found myself in this place after you clarified your problem. Here I found something you could appreciate. It is called "static."

http://lukearno.com/projects/static/

https://bitbucket.org/luke/static/

+7
source

Bottle supports PEP 3333, serving static files and very few. This may set you up. I agree with Mark Hildreth's answer, but if you need a static service for development and for working with Python 3, then Bottle is a good bet. Note. The bottle uses 2to3.

+2
source

Here are some links to WSGI application information 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 , and it is the section WSGI 1.0 and WSGI 1.1.

All of these links are taken from this page:

http://www.wsgi.org/wsgi/Python_3

It seems to me that the most mature at the moment is CherryPy. I am also sure that CherryPy provides an easy way to serve static files.

+1
source

Source: https://habr.com/ru/post/893123/


All Articles