home
pigwig is a WSGI framework for python 3.6+:
#!/usr/bin/env python3
import typing
from pigwig import PigWig, Response
if typing.TYPE_CHECKING:
from pigwig import Request
from pigwig.routes import RouteDefinition
def root(request: Request) -> Response:
return Response('hello, world!')
def shout(request: Request, word: str) -> Response:
return Response.json({'input': word, 'OUTPUT': word.upper()})
routes: RouteDefinition = [
('GET', '/', root),
('GET', '/shout/<word>', shout),
]
app = PigWig(routes)
if __name__ == '__main__':
app.main()
pigwig has no hard dependencies, but
- if you want to use templating, you must either install jinja2 or provide your own template engine
- if you want to use pigwig.PigWig.main for development, the reloader requires a libc that supports inotify (linux 2.6.13 and glibc 2.4 or later) or the macfsevents package on OS X
- you will want a "real" WSGI server to deploy on such as waitress, eventlet, or gunicorn
see blogwig for a more in-depth example and the readme for FACs