您的位置:首页 > Web前端 > JavaScript

pyjsonrpc模块使用

2018-07-04 22:25 1481 查看

  pyjsonrpc模块的远程过程调用方法。

# -*- coding:utf-8 -*-
#!/usr/bin/env python2.7
# @Author  : tianbao
# @Contact : gmu1592618@gmail.com
# @Time    : 2018/7/4 21:49
# @File    : aastest.py
# @Software: PyCharm
import pyjsonrpc

class RequestHandler(pyjsonrpc.HttpRequestHandler):

@pyjsonrpc.rpcmethod
def add(self, a, b):
"""Test method"""
return a + b

# Threading HTTP-Server
http_server = pyjsonrpc.ThreadingHttpServer(
server_address = ('localhost', 8080),  # 监听地址
RequestHandlerClass = RequestHandler
)
print "Starting HTTP server ..."
print "URL: http://localhost:8080"
http_server.serve_forever()                 # 启动
server

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: