gevent+itty 不错的新组合

By admin at 2014-02-06 17:48:33 • 684次点击

itty 一个新的python web 框架,代码风格跟bottle 相似。作者是Django 界很有名。

https://github.com/toastdriven/itty 1

示例

from itty import get, run_itty

@get('/')
def index(request):
    return 'Hello World!'

run_itty()

######################

from itty import *

@get('/get/(?P<name>\w+)')
def test_get(request, name=', world'):
    return 'Hello %s!' % name

@post('/post')
def test_post(request):
    return "'foo' is: %s" % request.POST.get('foo', 'not specified')

@put('/put')
def test_put(request):
    return "'foo' is: %s" % request.PUT.get('foo', 'not specified')

@delete('/delete')
def test_delete(request):
    return 'Method received was %s.' % request.method

run_itty()

gevent, itty


登录 后发表评论