{ "info": { "author": "Roman Mohr", "author_email": "roman@fenkhuber.at", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Libraries", "Topic :: Utilities" ], "description": ".. -*- mode: rst; coding: utf-8 -*-\n\nstatic3 - A really simple WSGI way to serve static (or mixed) content.\n====================================================================================\n\n.. image:: https://travis-ci.org/rmohr/static3.svg?branch=master\n :target: https://travis-ci.org/rmohr/static3\n\n.. contents:: Table of Contents\n :backlinks: top\n\nThis software is a Python3 compatible fork of Luke Arnos library static_.\n\nThe library is now Python3 compatible and Genshi_ support (the sucessor of\nkid_) is added. On Python2 Genshi and/or kid can be used as template engine. On\nPython3 only Genshi is available.\n\nThis library provides an easy way to include static content\nin your WSGI applications. There is a convenience method for serving\nfiles located via pkg_resources. There are also facilities for serving\nmixed (static and dynamic) content using \"magic\" file handlers.\nPython builtin string substitution, kid and Genshi template support are provided\nand it is easy to roll your own handlers. Note that this distribution\ndoes not require kid or Genshi unless you want to use that type of template. Also\nprovides a command of the same name as a convenience when you just want\nto share a little content over HTTP, ad hoc.\n\nInstallation and Usage\n----------------------\n\nLatest release via PIP::\n\n pip install static3\n\nInstallation via GitHub::\n\n git clone https://github.com/rmohr/static3.git\n cd static3\n pip install .\n\nCling\n^^^^^\n\n`Cling` serves static content only. Just give it the base directory with your\nfiles you want to make accessible. You get a full WSGI app with an example as\nsimple as that::\n\n from static import Cling\n from wsgiref.simple_server import make_server\n my_app = Cling(\"/my/directory\")\n make_server(\"localhost\", 9999, my_app).serve_forever()\n\nNow you can access everything in the given directory via http://localhost:9999.D\n\nServing compressed files\n^^^^^^^^^^^^^^^^^^^^^^^^\n\nIf a gzip compressed file with the \u00b4gz\u00b4 postfix is present, it is served, along with the corresponding headers.\nSo if the file 'index.html' and the file 'index.html.gz' are present, the file 'index.html.gz' is served, if the the client indicated that it supports gzipped content.\n\nAdditionally, you can configure arbitrary headers. You can match files by mime\ntype, file extension, or prefix. For example, the following would add\nCache-Control headers to paths with a css mime type for 10s, no-cache for all\npaths ending in .js for 100s, and add CORS header to all paths under the /imgs/\ndir::\n\n headers = [\n {'type': 'text/css', 'Cache-Control': 'max-age=10'},\n {'ext': '.js', 'Cache-Control': 'no-cache'},\n {'prefix': '/imgs/', 'Access-Control-Allow-Origin': '*'},\n ]\n Cling(\"/my/directory\", headers=headers)\n\n\nShock\n^^^^^\n\n`Shock` has the same basic functionality like `Cling` but with Shock we can\nalso have some templating fun. Shock comes with three templating backends.\nString substitution, kid and Genshi. The decision which backend to use is done\nby examining the extension of the file to serve. The file extensions are 'stp',\n'kid' and 'genshi'. So if you want to provide a file called 'index.html' via\nthe kid backend, name your file 'index.html.kid'. A short example might look\nlike this::\n\n from static import Shock, KidMagic\n from wsgiref.simple_server import make_server\n my_app = Shock(\"/my/directory\", magics=[KidMagic(title=\"Hello World\")])\n make_server(\"localhost\", 9999, my_app).serve_forever()\n\nAnd the example 'index.html.kid'::\n\n \n
\n \n \n