admin avatar

gevent+itty 不错的新组合

🕥 by admin

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

https://github.com/toastdriven/itty

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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()

💘 相关文章

写一条评论

Based on Golang + fastHTTP + sdb | go1.16.3 Processed in 1ms