Hi
I am trying to get to get the example working from the pyjamas
project (http://lkcl.net/webpy.jsonrpc.tgz), and have modified the
example code for what I hope would work with webpy 0.3 but can not
seem to get the example working.
Does any one have an example on webpy 0.3 of pyjamas and jsonrpc they
could share?
from network import JSONRPCService, jsonremote
import web
import os
urls = (
'/chat/', 'chatcls',
'/chat', 'chatcls',
'/(.*)', 'static' # static content
)
# to wrap static content like this is possibly a bit of an unnecessary
hack,
# but it makes me feel better. as i am unfamiliar with web.py, i
don't
# entirely know how it supports static content, so feel more
comfortable
# with doing it manually, here, with this "static" class.
class static:
def GET(self, name):
if name == '':
name = 'JSONRPCExample.html'
ext = name.split(".")[-1]
cType = {
"js":"application/x-javascript",
"txt":"text/plain",
"css":"text/css",
"html":"text/html",
"png":"images/png",
"jpg":"image/jpeg",
"gif":"image/gif",
"ico":"image/x-icon" }
if name in os.listdir('static/output'):
web.header("Content-Type", cType[ext])
#print open('static/output/%s'%name,"rb").read()
return open('static/output/%s'%name,"rb").read()
else:
raise web.notfound()
# a "wrapper" class around the jsonrpc service "chatservice"
class chatcls:
def POST(self):
#print chatservice(web.webapi.data())
return chatservice(web.webapi.data())
chatservice = JSONRPCService()
# the two demo functions
@jsonremote(chatservice)
def echo(request, user_name):
web.debug(repr(request))
return "hello world %s" % user_name
@jsonremote(chatservice)
def reverse(request, user_name):
return "hello world %s" % user_name[::-1]
app = web.application(urls, globals())
# start me!
if __name__ == "__main__":
#web.run(urls, globals())
app.run()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---