Skip to main content

WSGI Middleware for serving static files

Project description

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 localhost:8000/static/style.css
.foo {
    font-size: 10px;
}

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wsgi-static-middleware-0.0.3.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wsgi_static_middleware-0.0.3-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file wsgi-static-middleware-0.0.3.tar.gz.

File metadata

File hashes

Hashes for wsgi-static-middleware-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b17541727e0f6f6b6671694ffa84e9dd17352925edcaec0b80d5898a93411225
MD5 61770c22dbe735142155230c80fe1de5
BLAKE2b-256 dc74c491e894c62b89d5c5d7619d0a40520fb6a473aaece8a5f775552eed0548

See more details on using hashes here.

File details

Details for the file wsgi_static_middleware-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for wsgi_static_middleware-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ccfb9212ff1dc39462f54e263cb26783f148fca4805d8cc36d072555d46628ec
MD5 0acff1876dfe8bccad3c6102929db75b
BLAKE2b-256 93cb46adfcb268cb6733e3f2b110dd255bab5ddffe170449bdedac48171b2893

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page