2

按下按钮时,我想在新窗口上打开 html 文件。

但我做不到。请指教。

索引.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>test</title>
  </head>
  <body>
    <form action="./cgi-bin/openNewWindow.py" method="POST">
      <input type="submit">
    </form>
  </body>
</html>

打开新窗口.py

#!/usr/bin/env python
# coding: UTF-8

print("Content-type: text/html")
print("""
<!DOCTYPE html><html><head>
<meta charset="utf-8">
<title>new window</title>
</head><body>
<h1>new window</h1>
</body></html>
""")

cgiserver.py

#!/usr/bin/env python
# coding: UTF-8

import http.server

http.server.test(HandlerClass=http.server.CGIHTTPRequestHandler)
4

0 回答 0