当前位置: 首页>>代码示例>>Python>>正文


Python BaseHTTPRequestHandler.send_response方法代码示例

本文整理汇总了Python中http.server.BaseHTTPRequestHandler.send_response方法的典型用法代码示例。如果您正苦于以下问题:Python BaseHTTPRequestHandler.send_response方法的具体用法?Python BaseHTTPRequestHandler.send_response怎么用?Python BaseHTTPRequestHandler.send_response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在http.server.BaseHTTPRequestHandler的用法示例。


在下文中一共展示了BaseHTTPRequestHandler.send_response方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send_header

# 需要导入模块: from http.server import BaseHTTPRequestHandler [as 别名]
# 或者: from http.server.BaseHTTPRequestHandler import send_response [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'))
开发者ID:Ashafix,项目名称:jobManager,代码行数:9,代码来源:rest_server.py

示例2: send_response

# 需要导入模块: from http.server import BaseHTTPRequestHandler [as 别名]
# 或者: from http.server.BaseHTTPRequestHandler import send_response [as 别名]
 def send_response(self, code: Union[int, HTTPStatus], message=None):
     """Fill in HTTP status message if not set."""
     if message is None:
         if isinstance(code, HTTPStatus):
             message = code.phrase
             code = code.value
     BaseHTTPRequestHandler.send_response(self, code=code, message=message)
开发者ID:berkmancenter,项目名称:mediacloud,代码行数:9,代码来源:hash_server.py

示例3: send_response

# 需要导入模块: from http.server import BaseHTTPRequestHandler [as 别名]
# 或者: from http.server.BaseHTTPRequestHandler import send_response [as 别名]
 def send_response(self, mesg, code=200, headers=None):
     'Wraps sending a response down'
     if not headers:
         headers = {}
     if 'Content-Type' not in headers:
         headers['Content-Type'] = 'text/html'
     BaseHTTPRequestHandler.send_response(self, code)
     self.send_header('Content-Length', len(mesg))
     if headers:
         for k, v in headers.items():
             self.send_header(k, v)
     self.end_headers()
     self.wfile.write(mesg)
开发者ID:Ecostack,项目名称:python-impact,代码行数:15,代码来源:py3_server.py

示例4: send_header

# 需要导入模块: from http.server import BaseHTTPRequestHandler [as 别名]
# 或者: from http.server.BaseHTTPRequestHandler import send_response [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()
开发者ID:Ashafix,项目名称:monitor,代码行数:15,代码来源:monitor_server.py

示例5: send_response

# 需要导入模块: from http.server import BaseHTTPRequestHandler [as 别名]
# 或者: from http.server.BaseHTTPRequestHandler import send_response [as 别名]
 def send_response(self, code):
     """
     See Python's BaseHTTPRequestHandler.send_response().
     """
     BaseHTTPRequestHandler.send_response(self, code)
     self.send_header("Connection", "close")
开发者ID:alexkross,项目名称:exscript,代码行数:8,代码来源:HTTPd.py

示例6: send_response

# 需要导入模块: from http.server import BaseHTTPRequestHandler [as 别名]
# 或者: from http.server.BaseHTTPRequestHandler import send_response [as 别名]
 def send_response(self, code, message=None):
     BaseHTTPRequestHandler.send_response(self,
         self.server.override_code or code, message)
开发者ID:aaugustin,项目名称:django-resto,代码行数:5,代码来源:http_server.py


注:本文中的http.server.BaseHTTPRequestHandler.send_response方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。