实现dorset远程代理api的包
dorset的Python项目详细描述
安装
使用pip安装:
$ pip install dorset
用法
这个库处理请求和 来自Dorset应用程序的响应这支持创建 用python编写的远程代理。将此库与python框架一起使用 对于像烧瓶、瓶子或Django这样的RESTful api
web框架将处理HTTP请求和响应,并且 库将把请求解码为AgentRequest对象并将其编码 代理人的反应。
有了烧瓶,这看起来像:
app=Flask("dorset_hello")# required endpoint for the application to test if the agent is alive@app.route('/ping',methods=['GET'])defping():returnjson.dumps("pong")# primary endpoint@app.route('/request',methods=['POST'])defprocess():agent_request=Dorset.decode_request(request.data)print(agent_request.text)returnDorset.encode_response(text="hello, world!")