GithubHelp home page GithubHelp logo

adamchainz / aiohttp_utils Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sloria/aiohttp-utils

0.0 3.0 0.0 70 KB

Handy utilities for building aiohttp.web applications

Home Page: https://aiohttp-utils.readthedocs.org

License: MIT License

Python 100.00%

aiohttp_utils's Introduction

aiohttp_utils

Latest version

Travis-CI

aiohttp_utils provides handy utilities for building aiohttp.web applications.

  • Method-based handlers ("resources")
  • Content negotiation with JSON rendering by default
  • Local development server with auto-reloading
  • And more

Everything is optional. You can use as much (or as little) of this toolkit as you need.

from aiohttp import web
from aiohttp_utils import Response, routing, negotiation, run

app = web.Application(router=routing.ResourceRouter())

# Method-based handlers
class HelloResource:

    async def get(self, request):
        name = request.GET.get('name', 'World')
        return Response({
            'message': 'Hello ' + name
        })


app.router.add_resource_object('/', HelloResource())

# Content negotiation
negotiation.setup(
    app, renderers={
        'application/json': negotiation.render_json
    }
)

if __name__ == '__main__':
    # Development server
    run(
        app,
        app_uri='hello.app:app',
        reload=True,
        port=8000
    )

Install

$ pip install aiohttp_utils

Documentation

Full documentation is available at https://aiohttp-utils.readthedocs.org/.

License

MIT licensed. See the bundled LICENSE file for more details.

aiohttp_utils's People

Contributors

sloria avatar

Watchers

 avatar  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.