#!/usr/bin/python3
import sys
import socketserver
import socket
import http.server
import threading
import io
# Use supplied port
if sys.argv[1:]:
port = int(sys.argv[1])
else:
port = 8889
class RedirectTestHandler(http.server.SimpleHTTPRequestHandler):
def send_html_content(self, html_content):
length = len(html_content)
self.send_header("Content-Type", "text/html")
self.send_header("Content-Length", str(length))
self.send_header("Connection", "close")
self.send_header("Cache-control", "no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform")
self.send_header("Pragma", "no-cache")
self.end_headers()
f = io.BytesIO()
f.write(html_content)
f.seek(0)
self.copyfile(f, self.wfile)
def do_GET(self):
print("[%
Python 3.5 HTTP服务器端重定向测试脚本
最新推荐文章于 2024-04-22 16:07:30 发布