91 lines
2.5 KiB
HTML
91 lines
2.5 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
|
"http://www.w3.org/TR/html4/loose.dtd">
|
|
<html lang="en"><head><title>User's Guide:i2p.BaseHTTPServer - Wikipedia</title>
|
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
|
<meta name="robots" content="index,follow">
|
|
<link rel="shortcut icon" href="/favicon.ico">
|
|
<style type='text/css'><!--
|
|
/*/*/
|
|
a.new, #quickbar a.new { color: #CC2200; }
|
|
#quickbar { position: absolute; top: 4px; left: 4px; border-right: 1px solid gray; }
|
|
#article { margin-left: 152px; margin-right: 4px; }
|
|
/* */
|
|
//--></style>
|
|
</head>
|
|
|
|
<body bgcolor='#FFFFFF' onload=''>
|
|
<h1 class='pagetitle'>User's Guide:i2p.BaseHTTPServer</h1><p class='subtitle'>From Python-I2P.
|
|
|
|
|
|
<div class='bodytext'>
|
|
Emulates Python BaseHTTPServer module using I2P sockets.
|
|
|
|
|
|
<p>
|
|
|
|
<h2><a name="Overview"> Overview </a></h2>
|
|
|
|
<p>
|
|
The Python module is described at <a href="http://www.python.org/doc/current/lib/module-BaseHTTPServer.html" class='printable' title="http://www.python.org/doc/current/lib/module-BaseHTTPServer.html">http://www.python.org/doc/current/lib/module-BaseHTTPServer.html</a>
|
|
|
|
<p>
|
|
To get a server going, use:
|
|
|
|
<p>
|
|
<ul ><pre>
|
|
>>> from i2p import BaseHTTPServer
|
|
>>> BaseHTTPServer.test().
|
|
</pre>
|
|
</ul >
|
|
|
|
<p>
|
|
Consult the documentation for function test() to change basic server settings, such as the session name.
|
|
|
|
<p>
|
|
A fully customizable example:
|
|
|
|
<p>
|
|
<ul ><pre>
|
|
>>> from i2p import BaseHTTPServer
|
|
>>> session = "mytestxxx.i2p" # SAM session name
|
|
>>> class MyServer(BaseHTTPServer.HTTPServer): pass
|
|
>>> class MyRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): pass
|
|
>>> httpd = MyServer(session, MyRequestHandler)
|
|
>>> httpd.socket.dest
|
|
(Base64 Destination of server)
|
|
>>> httpd.serve_forever()
|
|
</pre>
|
|
</ul >
|
|
|
|
<p>
|
|
|
|
<h2><a name="Classes"> Classes </a></h2>
|
|
|
|
<p>
|
|
class <strong>BaseHTTPRequestHandler</strong>
|
|
<ul ><pre>
|
|
Same interface as Python class BaseHTTPServer.BaseHTTPRequestHandler.
|
|
</pre>
|
|
</ul >
|
|
class <strong>HTTPServer</strong>
|
|
<ul ><pre>
|
|
Same interface as Python class BaseHTTPServer.HTTPServer.
|
|
</pre>
|
|
</ul >
|
|
|
|
<p>
|
|
|
|
<h2><a name="Functions"> Functions </a></h2>
|
|
|
|
<p>
|
|
<strong>test</strong>(HandlerClass=BaseHTTPRequestHandler, ServerClass=HTTPServer, protocol='HTTP/1.0', session='mytestxxx.i2p')
|
|
<ul ><pre>
|
|
Test the HTTP request handler class.
|
|
This runs an I2P TCP server under SAM session 'session'. If a single command
|
|
line argument is given, the argument is used instead as the SAM session name.
|
|
</pre>
|
|
</ul >
|
|
|
|
<p>
|
|
</div>
|
|
</body></html> |