Hi Everybody, 

I am new in web.py. I am trying to connect my pyjamas example file with 
web.py server.

The file are in *C:\Pyjama\examples\WCP_Tool\output\WCP_Tool.html*
my server is placed as follows : *C:\Documents and 
Settings\dev1\Desktop\WebServer\webpy_jsonrpc\code.py*

==========================================================
 my code.py file is as follows :

from network import JSONRPCService, jsonremote
import web
import os


#render = web.template.render('C:\Pyjama\examples\WCP_Tool\output')

urls = (
    '/chat/', 'chatcls',
    '/chat',  'chatcls',
   #'/WCP_Tool', 'WCP_Tool',
    '/(.*)', '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 WCP_Tool:
   def POST(self):
      return "POST"

   def GET(self):
      return "GET"
      
class static:
   def POST(self, name):
      return "Hi through POST"
   
   def GET(self, name):
      if name == '':
         name = 'WCP_Tool.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"            }
         
         *static_location = 'C:\Pyjama\examples\WCP_Tool\output'*
*         if name in os.listdir(static_location):  *
*            web.header("Content-Type", cType[ext])            *
*            return open('%s/%s' % (static_location, name), "rb").read()*
*         *   
         else:
            web.notfound()
            
      else:
         return "not able find file"

# a "wrapper" class around the jsonrpc service "chatservice"
class chatcls:
    def POST(self):
        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]
    
# start me!
if __name__ == "__main__":
   #web.run(urls, globals())
*   app = web.application(urls, globals())*
*   app.run()*

==========================================================

*   in my WCP_Tool.py file, i am trying to connect using following lines *

if __name__ == '__main__':
*   pyjd.setup("http://127.0.0.1/examples/WCP_Tool/public/WCP_Tool.html";)*
   app = WCP_Tool()
   app.TestFilesearch()
   pyjd.run()

in my browser, when i type url =* http://localhost:8080/*

*it calls that file, but only background color and title of tab changes. 
other things not appearing  on screen.*

Is this proper or i am missing something ?, pls reply.

Regards & thanks,
Swapnil

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to