Skip to main content

wsgi-static-middleware

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

WSGI Middleware for serving static files.

Usage

import os
from wsgiref.simple_server import make_server
from wsgi_static_middleware import StaticMiddleware

BASE_DIR = os.path.dirname(__name__)
STATIC_DIRS = [os.path.join(BASE_DIR, 'static')]


def app(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 2016 03: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 2016 03:42:1473532953S GMT
< Accept-Ranges: bytes
<
.foo {
    font-size: 10px;
}
* Closing connection 0

LICENSE

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.

Metadata

Release files for wsgi-static-middleware 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wsgi-static-middleware 0.1.2
File Size Uploaded
wsgi-static-middleware-0.1.2.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wsgi-static-middleware 0.1.2
File Interpreter ABI Platform
wsgi_static_middleware-0.1.2-py2-none-any.whl Python 2 none any Details

Total release size: 10.6 kB

Release files / wsgi-static-middleware-0.1.2.tar.gz

Download URL wsgi-static-middleware-0.1.2.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7d58564cc74ff53d00d9973a9533685081343ee0cb929b0a1a1b4f2a17f6e2a1
BLAKE2b-256 checksum
How to use checksums
d7cc33e2b7b152139154b44d35dc69a60c33cff6050eed90ee2cef8e77702203
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / wsgi_static_middleware-0.1.2-py2-none-any.whl

Download URL wsgi_static_middleware-0.1.2-py2-none-any.whl
Size 6.6 kB
Tags Python 2
SHA-256 checksum
How to use checksums
e77aa5e2bd432d9b6b56d44a23c67a520309439ea888749e3d012cd7ff6eeda2
BLAKE2b-256 checksum
How to use checksums
f96c03fc86dcf25fb3b60dc81027ef06dc9c308bb00f0fa79d241263eb391099
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

3 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page