-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdemo.py
More file actions
32 lines (24 loc) · 711 Bytes
/
demo.py
File metadata and controls
32 lines (24 loc) · 711 Bytes
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
30
31
32
# -*- coding: utf-8 -*-
from zigmo import Application, BaseHandler, run_server
from concurrent import Return, coroutine
class AppHandler(BaseHandler):
@classmethod
def get(cls, **kwargs):
return "Marry Christmas"
class AsyncHandler(BaseHandler):
@classmethod
@coroutine
def yield_something(cls):
raise Return('value from yield')
@classmethod
@coroutine
def get(cls, *args, **kwargs):
result = yield cls.yield_something()
raise Return(result)
if __name__ == '__main__':
app = Application([
('/app', AppHandler),
('/\d+', AppHandler),
('/s', AsyncHandler),
])
run_server('0.0.0.0', 8080, application=app)