使用WSGI和Python 3提供静态文件 [英] Serving static files with WSGI and Python 3

查看:96
本文介绍了使用WSGI和Python 3提供静态文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用WSGI和Python 3.2提供静态文件的最简单方法是什么?有一些用于PEP 333和Python 2的WSGI应用程序-但是与PEP 3333和Python 3有关吗?我想使用wsgiref进行开发.

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.

推荐答案

通常,您不想使用WSGI提供静态文件.使用WSGI,以便可以使用Python生成动态内容.根据定义,静态文件不是动态内容,因此您不需要WSGI的附加层以及在其上构建的任何Web应用程序.相反,最好是将Web服务器(apache,nginx,iis等)设置为与WSGI应用程序一起单独提供静态文件.

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.

有趣的是,在您澄清了问题之后,我刚刚发现自己.这是我发现您可能会感激的.称为静态".

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/

这篇关于使用WSGI和Python 3提供静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆