本文整理汇总了Python中http.server.BaseHTTPRequestHandler.end_headers方法的典型用法代码示例。如果您正苦于以下问题:Python BaseHTTPRequestHandler.end_headers方法的具体用法?Python BaseHTTPRequestHandler.end_headers怎么用?Python BaseHTTPRequestHandler.end_headers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http.server.BaseHTTPRequestHandler
的用法示例。
在下文中一共展示了BaseHTTPRequestHandler.end_headers方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_header
# 需要导入模块: from http.server import BaseHTTPRequestHandler [as 别名]
# 或者: from http.server.BaseHTTPRequestHandler import end_headers [as 别名]
def send_header(BaseHTTPRequestHandler):
BaseHTTPRequestHandler.send_response(200)
BaseHTTPRequestHandler.send_header('Access-Control-Allow-Origin', '*')
BaseHTTPRequestHandler.send_header('Content-type:', 'text/html')
BaseHTTPRequestHandler.end_headers()
BaseHTTPRequestHandler.wfile.write(bytes('\n', 'utf-8'))
BaseHTTPRequestHandler.wfile.write(bytes('<html>\n', 'utf-8'))
示例2: test
# 需要导入模块: from http.server import BaseHTTPRequestHandler [as 别名]
# 或者: from http.server.BaseHTTPRequestHandler import end_headers [as 别名]
def test(handler):
sess_id = handler.query.split('=',1)[1]
handler.send_response(200)
handler.send_header("Content-type", "text/html")
msg = "{}={}".format(sess_id, 1000)
handler.send_header("Content-length", str(len(msg)))
handler.send_header("Connection", "close")
handler.end_headers()
BaseHTTPRequestHandler.end_headers(handler)
handler.wfile.write("{}!".format(msg))
示例3: send_header
# 需要导入模块: from http.server import BaseHTTPRequestHandler [as 别名]
# 或者: from http.server.BaseHTTPRequestHandler import end_headers [as 别名]
def send_header(BaseHTTPRequestHandler, format='HTML'):
if format.upper() == 'HTML':
BaseHTTPRequestHandler.send_response(200)
BaseHTTPRequestHandler.send_header('Access-Control-Allow-Origin', '*')
BaseHTTPRequestHandler.send_header('Content-type:', 'text/html')
BaseHTTPRequestHandler.end_headers()
BaseHTTPRequestHandler.wfile.write(bytes('\n', 'utf-8'))
BaseHTTPRequestHandler.wfile.write(bytes('<html>\n', 'utf-8'))
elif format.upper() == 'JSON':
BaseHTTPRequestHandler.send_response(200)
BaseHTTPRequestHandler.send_header('Access-Control-Allow-Origin', '*')
BaseHTTPRequestHandler.send_header('Content-type:', 'application/json')
BaseHTTPRequestHandler.end_headers()
示例4: end_headers
# 需要导入模块: from http.server import BaseHTTPRequestHandler [as 别名]
# 或者: from http.server.BaseHTTPRequestHandler import end_headers [as 别名]
def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')
BaseHTTPRequestHandler.end_headers(self)
示例5: end_headers
# 需要导入模块: from http.server import BaseHTTPRequestHandler [as 别名]
# 或者: from http.server.BaseHTTPRequestHandler import end_headers [as 别名]
def end_headers(self):
self.send_my_headers()
BaseHTTPRequestHandler.end_headers(self)
示例6: end_headers
# 需要导入模块: from http.server import BaseHTTPRequestHandler [as 别名]
# 或者: from http.server.BaseHTTPRequestHandler import end_headers [as 别名]
def end_headers(self):
if self.request_version <= 'HTTP/1.1':
BaseHTTPRequestHandler.end_headers(self)
elif self.request_version == 'HTTP/2.0':
self.flush_headers()