CARVIEW |
Select Language
HTTP/2 200
server: nginx
content-type: text/html;charset=utf-8
cache-control: must-revalidate
expires: Fri, 01 Jan 1999 00:00:00 GMT
set-cookie: trac_form_token=6a90323412b043ecf96522eb; HttpOnly; Path=/; Secure
set-cookie: trac_session=ff011f806641589cec3627db; expires=Tue, 21 Oct 2025 06:05:02 GMT; HttpOnly; Path=/; Secure
strict-transport-security: max-age=31536000; includeSubDomains; preload
permissions-policy: interest-cohort=()
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
accept-ranges: bytes
via: 1.1 varnish, 1.1 varnish
date: Wed, 23 Jul 2025 06:05:02 GMT
x-served-by: cache-fra-etou8220115-FRA, cache-bom-vanm7210037-BOM
x-cache: MISS, MISS
x-cache-hits: 0, 0
x-timer: S1753250702.340110,VS0,VE335
vary: Accept-Encoding
JSON-RPC – Django
Back to Top
Django
The web framework for perfectionists with deadlines.
Issues
Simply see XML-RPC . Use the SimpleJSONRPCServer instead of SimpleXMLRPCServer and you are done!
You'll also want JSON RPC Client too.
$ cat testjsonrpc.py import sys import jsonrpclib rpc_srv = jsonrpclib.ServerProxy("https://localhost:8000/json_rpc_srv/") result = rpc_srv.multiply( int(sys.argv[1]), int(sys.argv[2])) print "%d * %d = %d" % (int(sys.argv[1]), int(sys.argv[2]), result['result'])
There you go!
django-json-rpc
Another, easier to use JSON-RPC implementation.
Features:
- Simple, pythonic API
- Support for Django authentication
- Mostly supports JSON-RPC 1.1 spec
- Proxy to test your JSON Service
The basic API:
### myproj/myapp/views.py from jsonrpc import jsonrpc_method @jsonrpc_method('myapp.sayHello') def whats_the_time(request, name='Lester'): return "Hello %s" % name @jsonrpc_method('myapp.gimmeThat', authenticated=True) def something_special(request, secret_data): return {'sauce': ['authenticated', 'sauce']} ### myproj/urls.py from jsonrpc import jsonrpc_site import myproj.myapp.views # you must import the views that need connected urls += patterns('', (r'^json/', jsonrpc_site.dispatch))
To test your service:
>>> from jsonrpc.proxy import ServiceProxy >>> s = ServiceProxy('https://localhost:8080/json/') >>> s.myapp.sayHello('Sam') {u'error': None, u'id': u'jsonrpc', u'result': u'Hello Sam'} >>> s.myapp.gimmeThat('username', 'password', 'test data') {u'error': None, u'id': u'jsonrpc', u'result': {u'sauce': [u'authenticated', u'sauce']}}
Last modified
16 years ago
Last modified on Jul 6, 2009, 4:53:06 PM
Note:
See TracWiki
for help on using the wiki.
Download in other formats:
Django Links
Learn More
Get Involved
Follow Us
- Hosting by In-kind donors
- Design by Threespot &
© 2005-2025 Django SoftwareFoundation unless otherwise noted. Django is a registered trademark of the Django Software Foundation.