a python 3.6+ WSGI framework
Project description
pigwig
a pig wearing a wig is humor
a wig wearing a pig is heresy
pigwig is a python 3 WSGI framework
(blogwig is a sample app. don't put wigs on blogs)
#!/usr/bin/env python3
from pigwig import PigWig, Response
def root(request):
return Response('hello, world!')
routes = [
('GET', '/', root),
]
app = PigWig(routes)
if __name__ == '__main__':
app.main()
FACs (frequent, annoying comments)
- tornado-style class-based views are better
we think you're wrong (inheritance is a hammer and this problem is no nail), but it's easy enough to achieve:def routes(): views = [ ('/', RootHandler), ] handlers = [] for route, view in views: for verb in ['get', 'post']: if hasattr(view, verb): handlers.append((verb.upper(), route, cbv_handler(view, verb))) return handlers def cbv_handler(cbv, verb): def handler(request): return getattr(cbv(request), verb)() return handler class RootHandler: def __init__(self, request): self.request = request def get(self): return Response('hello')
- flask-style decorator-based routing is better
we think you're wrong (explicit is better than implicit), but it's easy enough to achieve:routes = [] def route(path, method='GET'): def wrapper(handler): routes.append((method, path, handler)) return handler return wrapper @route('/') def root(request): return Response('hello')
- django-style integration with an ORM is better
you're wrong
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pigwig-0.8.1.tar.gz
(13.6 kB
view details)
Built Distribution
pigwig-0.8.1-py3-none-any.whl
(15.6 kB
view details)
File details
Details for the file pigwig-0.8.1.tar.gz
.
File metadata
- Download URL: pigwig-0.8.1.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 941d9348778e4c9f4b344a5ae3ebefe6f6ca606f9a1cacc3ccc3628332938dba |
|
MD5 | b86fa4e5eac759dcf7c250f00f4ab568 |
|
BLAKE2b-256 | 42df02b2fa50a9aa82acbcadb6250fd3cf97b97e290c3802934a81c2d7ace343 |
File details
Details for the file pigwig-0.8.1-py3-none-any.whl
.
File metadata
- Download URL: pigwig-0.8.1-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ca14ff76a6d495b295ffaecf31a71a1a36fcad6caaffae33e7c0e8332017b64 |
|
MD5 | d202ad7056a56c01d29a80c29ecdd836 |
|
BLAKE2b-256 | f8531bc588dc86d795756b40511f2f3cc1781099d53188ce7d388de1d3b6aff1 |