forked from the-benchmarker/web-frameworks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
32 lines (24 loc) · 809 Bytes
/
server.py
File metadata and controls
32 lines (24 loc) · 809 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
import cyclone.web
from twisted.application import internet
from twisted.application import service
class MainHandler(cyclone.web.RequestHandler):
@cyclone.web.asynchronous
def get(self):
self.write("")
self.finish()
class UserInfoHandler(cyclone.web.RequestHandler):
@cyclone.web.asynchronous
def get(self, id):
self.write(id)
self.finish()
class UserHandler(cyclone.web.RequestHandler):
@cyclone.web.asynchronous
def post(self):
self.write("")
self.finish()
routes = cyclone.web.Application(
[(r"/", MainHandler), (r"/user/(\d+)", UserInfoHandler), (r"/user", UserHandler)]
)
application = service.Application("benchmark")
server = internet.TCPServer(3000, routes, interface="0.0.0.0")
server.setServiceParent(application)