Skip to content

hirunatan/anillo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anillo nanoframework

Build Status Coveralls Status Development Status Latest Version Supported Python versions License Downloads

Anillo is a Ring/Compojure inspired nanoframework build on top of werkzeug library using some utilities and the routing system.

The idea is create a really slim abstraction layer between WSGI and my handlers, with the less quantity of opinion about what are you implementing.

You can use any template system, storage system or whatever you want, you only receive a Request (a dict object) and must return a Response (another dict object).

Middlewares

You can build middlewares writing decorators, and decorating your handlers or the router handler, if you want to affect everything.

Routes handling

Anillo comes with a route handler based on Werkzeug Router.

Examples

Basic example

from anillo.app import application
from anillo.http import Ok


def index(request):
    return Ok("Hello World!")


app = application(index)


if __name__ == '__main__':
    from anillo import serving
    serving.run_simple(app, port=5000)

Basic with middleware

from anillo.app import application
from anillo.utils.common import chain
from anillo.http import Ok


def middleware(func):
    def wrapper(request):
        request.new_data = "Middleware data"
        return func(request)
    return wrapper


def index(request):
    return Ok(request.new_data)


app = application(chain(middleware, index))


if __name__ == '__main__':
    from anillo import serving
    serving.run_simple(app, port=5000)

Basic with routing

from anillo.app import application
from anillo.handlers.routing import router, url
from anillo.http import Ok


def index(request):
    return Ok("Index")


def hello(request):
    return Ok("Hello World!")

urls = [
    url("/", index),
    url("/hello", hello, methods=["get"]),
]

app = application(router(urls))

if __name__ == '__main__':
    from anillo import serving
    serving.run_simple(app, port=5000)

About

Ring/compojure like nanoframework build on top of werkzoug

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.6%
  • Shell 0.4%