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.
Fortunately uWSGI has a wide series of options and micro-optimizations for serving static files. Generally your webserver of choice (Nginx, Mongrel2, etc.) will serve static files efficiently and quickly and will simply forward dynamic requests to uWSGI backend nodes.
Django's primary deployment platform is WSGI, the Python standard for web servers and applications. Django's startproject management command sets up a minimal default WSGI configuration for you, which you can tweak as needed for your project, and direct any WSGI-compliant application server to use.
Your First WSGI App Call it app.py and run it with any WSGI-compatible server and you'll get a Hello World response with a 200 status. You can use gunicorn for this; just install it via pip ( pip install gunicorn ) and run it with gunicorn app:app .
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".
https://github.com/lukearno/static
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With