Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Latest commit

 

History

History
51 lines (38 loc) · 918 Bytes

readme.md

File metadata and controls

51 lines (38 loc) · 918 Bytes

why

http servers should be easier and simpler.

what

a port of ring to tornado for python3.

install

note: tested only on ubuntu

git clone https://github.com/nathants/py-web
cd py-aws
pip3 install -r requirements.txt
pip3 install .

example

#!/usr/bin/env python3.6
import logging
import tornado.gen
import tornado.ioloop
import web

logging.basicConfig(level='INFO')

@tornado.gen.coroutine
def handler(request):
    yield None # must yield at least once
    size = request['query']['size']
    token = request['kwargs']['token']
    return {'code': 200,
            'body': f'{token} size: {size}'}

routes = [
    ('/hello/:token', {'get': handler}),
]

app = web.app(routes)
app.listen(8080)
tornado.ioloop.IOLoop.current().start()
$ curl localhost:8080/hello/world?size=3
world size: 3