forked from qiu0130/Qkindle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app_test.py
46 lines (28 loc) · 939 Bytes
/
app_test.py
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
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: UTF-8 -*-
# Created by qiu on 16-5-20
#
if __name__ == "__main__":
pass
from tornado.httpclient import AsyncHTTPClient
from tornado.gen import coroutine
from tornado.web import RequestHandler
from tornado.escape import json_decode
import tornado.web
import tornado.httpserver
import tornado.ioloop
class Mainhandler(RequestHandler):
@coroutine
def get(self):
http_client = AsyncHTTPClient()
reponse = yield http_client.fetch("http://127.0.0.1:8887/pushbook", method = "POST",
body = str({
"body": "body --- "
}))
self.write(json_decode(reponse.body)["body"])
if __name__ == "__main__":
app = tornado.web.Application([
(r"/test", Mainhandler),
], debug=True)
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(8875)
tornado.ioloop.IOLoop.current().start()