Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
ab807e8a
Kaydet (Commit)
ab807e8a
authored
Ara 01, 2004
tarafından
Andrew M. Kuchling
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make the example server code clearer; add the corresponding example client. [Bugfix candidate]
üst
9cc5cb7c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
5 deletions
+36
-5
libsimplexmlrpc.tex
Doc/lib/libsimplexmlrpc.tex
+36
-5
No files found.
Doc/lib/libsimplexmlrpc.tex
Dosyayı görüntüle @
ab807e8a
...
...
@@ -88,18 +88,49 @@ simple, stand alone XML-RPC servers.
Example:
\begin{verbatim}
class MyFuncs:
def div(self, x, y) : return x // y
from SimpleXMLRPCServer import SimpleXMLRPCServer
# Create server
server = SimpleXMLRPCServer(("localhost", 8000))
server.register
_
function(pow)
server.register
_
function(lambda x,y: x+y, 'add')
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
server.register
_
instance(MyFuncs())
# Run the server's main loop
server.serve
_
forever()
\end{verbatim}
The following client code will call the methods made available by
the preceding server:
\begin{verbatim}
import xmlrpclib
s = xmlrpclib.Server('http://localhost:8000')
print s.pow(2,3) # Returns 2**3 = 8
print s.add(2,3) # Returns 5
print s.div(5,2) # Returns 5//2 = 2
# Print list of available methods
print s.system.listMethods()
\end{verbatim}
\subsection
{
CGIXMLRPCRequestHandler
}
The
\class
{
CGIXMLRPCRequestHandler
}
class can be used to
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment