GithubHelp home page GithubHelp logo

niwinz / anillo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jespino/anillo

0.0 2.0 0.0 215 KB

Ring/compojure like nanoframework build on top of werkzoug

License: BSD 2-Clause "Simplified" License

Python 99.60% Shell 0.40%

anillo's Introduction

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),
]

app = application(router(urls))

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

anillo's People

Contributors

hirunatan avatar jespino avatar niwinz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.