Przeglądaj źródła

created class

created method for initializing CHAP
master
DragonSkills99 5 lat temu
rodzic
commit
a1eb0b142a
1 zmienionych plików z 10 dodań i 14 usunięć
  1. 10
    14
      chap-server.py

+ 10
- 14
chap-server.py Wyświetl plik

@@ -1,6 +1,6 @@
#!/usr/bin/env python2

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

@@ -13,21 +13,17 @@ server = SimpleXMLRPCServer(("localhost", 8000),
requestHandler=RequestHandler)
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
# 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
server.serve_forever()

Ładowanie…
Anuluj
Zapisz