Skip to content

a simple package you can use tornado to build an api server using flask style

Notifications You must be signed in to change notification settings

OldDriverPickMeUp/meeepo_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

meeepo_api

a simple package you can use tornado to build an api server using flask style

now will only support tornado 5

get started

register a controller

from meeepo import controller
from meeepo.view import JsonView


@controller(r'/api/(?P<name>.*)/hello', ('get', 'post'))
async def your_controller(req, name):
    anything_else = req.get_argument('anything_else')
    some_data = {name: 'hello, this is {}'.format(name), 'anything else?': anything_else}
    return JsonView(some_data)
    

start your api server

from meeepo import start_server
 
 
def startup():
    scan_path = 'example_app/controllers'
    port = 8080
    start_server(scan_path, port)
 
 
if __name__ == '__main__':
    startup()

test

$ curl -XGET localhost:8080/api/tornado/hello
{"tornado": "hello, this is tornado", "anything else?": null}
$ curl -XPOST localhost:8080/api/kenny/hello?anything_else=not_dead_yet
{"kenny": "hello, this is kenny", "anything else?": "not_dead_yet"}

About

a simple package you can use tornado to build an api server using flask style

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages