After going through the examples, there seems to be a problem with getting POST data to the server, so after a small edit, GET works fine.
By default simpleapi client sends POST data, we will need to make a small change to make it send GET data. In /lib/python2.7/site-packages/simpleapi/client/client.py, line 62, change
client.py
try: response = urllib.urlopen(self.ns, urllib.urlencode(data))
Change to:
try: response = urllib.urlopen(self.ns % urllib.urlencode(data))
from flask import Flask from simpleapi import Route from handler import calculator app = Flask(__name__) app.route('/api/', methods=['GET'])(Route(calculator, framework='flask', debug=True)) if __name__ == '__main__': app.run(host='0.0.0.0', port=8888, debug=True)
Client
#!/usr/bin/env python from simpleapi import Client, RemoteException calculator = Client(ns='http://127.0.0.1:8888/api/?%s') print "the answer is", calculator.add(a=23, b=3)
Best post.
ReplyDeleteFull Stack Training in Chennai | Certification | Online Training Course| Full Stack Training in Bangalore | Certification | Online Training Course | Full Stack Training in Hyderabad | Certification | Online Training Course | Full Stack Developer Training in Chennai | Mean Stack Developer Training in Chennai | Full Stack Training | Certification | Full Stack Online Training Course