使用Python CGI在新窗口中打开html文件

时间:2014-04-07 10:16:30

标签: python html python-3.4

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

但我做不到。请指教。

的index.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>

openNewWindow.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)

0 个答案:

没有答案