python实现简单的http接口
python3.6实现http接口服务,给别人调用,支持传参
Tornado是一个Python web框架和异步网络库
二、Tornado的get接口代码实现
pip install tornado
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
"""get请求"""
a = self.get_argument('a')
b = self.get_argument('b')
c = int(a) + int(b)
self.write("c=" + str(c))
application = tornado.web.Application([(r"/add", MainHandler), ])
if __name__ == "__main__":
application.listen(8868)
tornado.ioloop.IOLoop.instance().start()
浏览器访问:
postman调用

浙公网安备 33010602011771号