<s> import os <EOL> import cherrypy <EOL> from cherrypy import log <EOL> from pyjs . jsonrpc import JSONRPCServiceBase <EOL> class JSONRPCService ( JSONRPCServiceBase ) : <EOL> def __init__ ( self , defaultPage = '<STR_LIT>' ) : <EOL> JSONRPCServiceBase . __init__ ( self ) <EOL> self . defaultPage = defaultPage <EOL> '''<STR_LIT>''' <EOL> @ cherrypy . expose <EOL> def default ( self , * args ) : <EOL> try : <EOL> filename = os . path . join ( os . getcwd ( ) , args [ <NUM_LIT:0> ] ) <EOL> except : <EOL> filename = os . path . join ( os . getcwd ( ) , self . defaultPage ) <EOL> if os . path . isfile ( filename ) : <EOL> log ( os . linesep + '<STR_LIT>' % filename ) <EOL> f = file ( filename ) <EOL> s = f . read ( ) <EOL> f . close ( ) <EOL> return s <EOL> log ( os . linesep + '<STR_LIT>' % filename ) <EOL> '''<STR_LIT>''' <EOL> @ cherrypy . expose <EOL> def services ( self , * args ) : <EOL> data = cherrypy . request . body . read ( ) <EOL> log ( os . linesep + '<STR_LIT>' % data ) <EOL> return self . process ( data ) </s>
