wsgi microframework suitable for building modular DRY RESTful APIs
Project description
madness: a method for your madness
It is built upon WSGI and the fabulous werkzeug routing system, like Flask.
Guiding Principles
Dependency inversion principle
Goals
Installing
$ pip install -U madness
A Simple Example
from madness import application, get
def hello():
return 'Hello, world!'
if __name__ == '__main__':
application(get('/', hello)).run()
Routing
-
route and variants
-
routes and variants
-
defaults
-
url parameters
from madness import routes, route, get, post, index
def hello():
return 'world'
def bar():
return 'zing!'
# recommended style
urls = routes(
index(hello),
routes(
index(lambda: 'foo')
route(bar, methods=['GET', 'POST', 'PUT']),
path = '/foo'
)
)
# flat style
urls = routes(
route('/', hello, methods=['GET']),
route('/foo', lambda: 'foo', methods=['GET']),
route('/foo/bar', bar, methods=['GET', 'POST', 'PUT']),
)
# add GET to all routes
urls = routes(
route('/', hello),
route('/foo', lambda: 'foo'),
route('/foo/bar', bar, methods=['POST', 'PUT']),
methods = ['GET']
)
Abstractions (Dependency inversion principle)
-
g
-
extending g
-
madness.G and g_factory
Middleware (Coroutines)
as decorator
as serializer
as request-contextmanager
as response contextmanager
as request-response contextmanager
as error handler
Extensions
-
json
-
cors
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
madness-0.7.0.tar.gz
(5.1 kB
view details)
Built Distribution
File details
Details for the file madness-0.7.0.tar.gz
.
File metadata
- Download URL: madness-0.7.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9ca388fe1bbebf4c8b0efc9b7535c251366957b2a591da96bbcd6ccc7d94abd |
|
MD5 | f9a064830b94959f193926c232ab48f3 |
|
BLAKE2b-256 | 6246e5347b3ab396e299a58f4e3359b3adad3abb9da51ef34e12675f6f2560c5 |
File details
Details for the file madness-0.7.0-py3-none-any.whl
.
File metadata
- Download URL: madness-0.7.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccb1b768e3d5c1589c1de4885918a3ff82a547901893c87918c53476d181b994 |
|
MD5 | 34221f1430c568b503fc35c6f7cbe1e4 |
|
BLAKE2b-256 | 3da78df6e4a2b8e7e476179537e5f738b899e5e598553d3d3a0eaf4cbf0f50fd |