我有一个巨大的文本段存储在名为'text'的std :: string中.在这个字符串上,我使用boost regex库用空格替换某些模式.这是我的代码.
// Remove times of the form (00:33) and (1:33)
boost::regex rgx("\\([0-9.:]*\\)");
text = boost::regex_replace(text, rgx, " ");
// Remove single word HTML tags
rgx.set_expression("<[a-zA-Z/]*>");
text = boost::regex_replace(text, rgx, " ");
// Remove comments like [pause], [laugh]
rgx.set_expression("\\[[a-zA-Z]* *[a-zA-Z]*\\]");
text = boost::regex_replace(text, rgx, " ");
// Remove comments of the form <...>
rgx.set_expression("<.+?>");
text = boost::regex_replace(text, rgx, " ");
// Remove comments of the form {...}
rgx.set_expression("\\{.+?\\}");
text = boost::regex_replace(text, rgx, " ");
// Remove comments of …Run Code Online (Sandbox Code Playgroud) 我有一个基于 BaseHTTPServer 的简单服务器的以下代码。
class myHandler(BaseHTTPRequestHandler):
#Handler for the GET requests
def do_GET(self):
# Parse the query_str
query_str = self.path.strip().lower()
if query_str.startswith("/download?"):
query_str = query_str[10:]
opts = urlparse.parse_qs(query_str)
# Send the html message and download file
self.protocol_version = 'HTTP/1.1'
self.send_response(200)
self.send_header("Content-type", 'text/html')
self.send_header("Content-length", 1)
self.end_headers()
self.wfile.write("0")
# Some code to do some processing
# ...
# -----------
self.wfile.write("1")
Run Code Online (Sandbox Code Playgroud)
我原本期望 HTML 页面显示“1”,但它显示“0”。如何通过 keepalived 更新响应?