Explorar el Código

created class

created method for initializing CHAP
master
DragonSkills99 hace 6 años
padre
commit
a1eb0b142a
Se han modificado 1 ficheros con 10 adiciones y 14 borrados
  1. 10
    14
      chap-server.py

+ 10
- 14
chap-server.py Ver fichero

#!/usr/bin/env python2 #!/usr/bin/env python2


import uuid
from xmlrpc.server import SimpleXMLRPCServer from xmlrpc.server import SimpleXMLRPCServer
from xmlrpc.server import SimpleXMLRPCRequestHandler from xmlrpc.server import SimpleXMLRPCRequestHandler


requestHandler=RequestHandler) requestHandler=RequestHandler)
server.register_introspection_functions() server.register_introspection_functions()


# Register pow() function; this will use the value of
# pow.__name__ as the name, which is just 'pow'.
server.register_function(pow)

# Register a function under a different name
def adder_function(x,y):
return x + y
server.register_function(adder_function, 'add')


# Register an instance; all the methods of the instance are # Register an instance; all the methods of the instance are
# published as XML-RPC methods (in this case, just 'div').
class MyFuncs:
def div(self, x, y):
return x // y
# published as XML-RPC methods
class CHAP:
def __init__(self):
self.key = 0;

def init(self):
self.key = str( uuid.uuid4() )
return self.key


server.register_instance(MyFuncs())
server.register_instance(CHAP())
# Run the server's main loop # Run the server's main loop
server.serve_forever() server.serve_forever()

Cargando…
Cancelar
Guardar