服务静态文件的wsgi中间件

wsgi-static-middleware的Python项目详细描述


https://travis-ci.org/kobinpy/wsgi-static-middleware.svg?branch=masterhttps://badge.fury.io/py/wsgi-static-middleware.svg

用于服务静态文件的wsgi中间件。

用法

importosfromwsgiref.simple_serverimportmake_serverfromwsgi_static_middlewareimportStaticMiddlewareBASE_DIR=os.path.dirname(__name__)STATIC_DIRS=[os.path.join(BASE_DIR,'static')]defapp(env,start_response):start_response('200 OK',[('Conte-type','text/plain; charset=utf-8')])return[b'Hello World']app=StaticMiddleware(app,static_root='static',static_dirs=STATIC_DIRS)if__name__=='__main__':httpd=make_server('',8000,app)httpd.serve_forever()
$ curl -v localhost:8000/static/style.css
*   Trying ::1...
* connect to ::1 port 8000 failed: Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8000(#0)
> GET /static/style.css HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.43.0
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Date: Sun, 11 Sep 201603:42:33 GMT
< Server: WSGIServer/0.2 CPython/3.5.1
< Content-Encodings:
< Content-Type: text/css;charset=UTF-8
< Content-Length: 30
< Last-Modified: Sun, 11 Sep 201603:42:1473532953S GMT
< Accept-Ranges: bytes
<
.foo {
    font-size: 10px;}
* Closing connection 0

许可证

MIT License

Copyright (c) 2016 Masashi SHIBATA

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
用户界面如何在JavaGUI中为按钮创建各种颜色?   使用MSCAPI的RSA密钥包装的java使用   java Spring数据Redis JedisConnectionException:意外的流结束   java饼图未显示预期输出   java hystrixCommand注释commandKey的用途是什么   windows java可以从cmd运行jar,但不能通过双击来运行   java在单击按钮时遍历XML节点   java试图使用日期(int,int,int)构造函数   带有Buildship 2子项目的java不作为项目依赖项链接   java jsonrpc4j:如何从服务器获取列表<SomeObject>?   用于Java应用程序的内存设置MaxDirectMemory和MaxHeapMemory   java如何从以下类型格式化日期   javayoutube。搜索列表搜索不返回任何内容   java My参数在方法中不起作用,因为泛型存在问题   java如何将Map<Key1Type,Val1Type>转换为Map<Key1Type,Val2Type>   JavaJUnit测试:测试用例的改进,测试数组列表的长度?   java如何在Android中解析带有属性值的xml数据?   使用Hibernate对枚举类型进行Java8bean验证