Skip to main content

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

Don't repeat yourself

Dependency inversion principle

Do One Thing and Do It Well.

The Zen of Python

Goals

Cohesion

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.

Files for madness, version 0.7.0
Filename, size File type Python version Upload date Hashes
Filename, size madness-0.7.0-py3-none-any.whl (7.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size madness-0.7.0.tar.gz (5.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page