|
|
|
|
|
|
|
[Original]
[Print]
[Top]
|
呵呵,各位大哥帮个忙,请在下面程序中的----------处加入一些东西,
谢谢
"""server3151
Translate Formal Public Identifiers (FPI) to URN format according
to the proposal of RFC3151
Usage: server3151 port
"""
__version__ = "1.0"
from BaseHTTPServer import HTTPServer,BaseHTTPRequestHandler
""" View the code and comments in BaseHTTPServer.py for assistance, examples, hints
for doing the question below """
import sys
import trans3151
class RFC3151(BaseHTTPRequestHandler):
"""Class overrides the do_GET method of the simple handler."""
def do_GET(self):
s = self.path
"""
Extract the FPI from the path. Be aware that the path will
#have been encoded using the 'quoted' encoding
#before being sent by the browser.
(1) fpi = ---------------"""
"""Call the translation module transform FPI to URN"""
urn = trans3151.translate_double_slash(fpi)
"""Send an OK response according to RFC2616
(2) self. --------------------"""
"""Send a header specifiying the content type of the body data
(3) self. --------------------"""
"""Send a header specifying how much data is being sent
(4) self.----------------------"""
"""End the headers
(5) self. ------------"""
"""Use the wfile object to write the URN back to the client"""
self.wfile.write(urn)
# Get port from command line
port = int(sys.argv[1])
# '' accepts requests from anywhere
server_address = ('', port)
# Create an HTTP server listening on port with our request handler
httpd = HTTPServer(server_address, RFC3151)
print "RFC3151 server on port " + str(httpd.socket.getsockname()[1])
# Serve - program does not terminate
httpd.serve_forever()
|
|
|
[Original]
[Print]
[Top]
|
|
|