Python、BasicHTTPServer、およびSimpleHTTPServerを使用して、テスト目的で小さなWebサーバーを作成しています。一度に 1 つの要求を処理しているようです。あまり深くいじることなく、少し速くする方法はありますか? 基本的に、私のコードは次のようになります。このようにシンプルに保ちたいと思います;)
os.chdir(webroot)
httpd = BaseHTTPServer.HTTPServer(("", port), SimpleHTTPServer.SimpleHTTPRequestHandler)
print("Serving directory %s on port %i" %(webroot, port) )
try:
httpd.serve_forever()
except KeyboardInterrupt:
print("Server stopped.")