СGI python3 403 错误
СGI python3 403 error
我问这个是因为我写的应用程序非常简单,但它不起作用。
我在 /dir
:
的终端中写了这个命令
python3 -m http.server --cgi
我的脚本在 dir/cgi-bin/hp.py 中,代码为:
#!/usr/bin/env python3
print"Content-type: text/html"
print()
print"<h1>Hello world!</h1>"
这是我在浏览器 window 中看到的:
Error response
Error code: 403
Message: CGI script is not executable ('/cgi-bin/hp.py').
Error code explanation: HTTPStatus.FORBIDDEN - Request forbidden --
authorization will not help."
我该如何解决?
以下是我尝试重现问题的步骤:
# app.py
print("Content-type: text/html")
print()
print("<h1>Hello world!</h1>")
- 在
cgi-bin
目录中创建了文件 app.py
- 使用命令 运行 http.server 和 cgi
python -m http.server --bind localhost --cgi 8000
我尝试访问路径 "http:localhost/cgi-bin/"
得到 错误 403
现在是 解析 部分,即在浏览器中打开 link。
我运行命令:
python -mwebbrowser http://localhost:8000/cgi-bin/app.py
一段时间后它给了我结果,我也能够访问第 2 步的 link。
希望对你有所帮助。
结果:
我问这个是因为我写的应用程序非常简单,但它不起作用。
我在 /dir
:
python3 -m http.server --cgi
我的脚本在 dir/cgi-bin/hp.py 中,代码为:
#!/usr/bin/env python3
print"Content-type: text/html"
print()
print"<h1>Hello world!</h1>"
这是我在浏览器 window 中看到的:
Error response
Error code: 403
Message: CGI script is not executable ('/cgi-bin/hp.py').
Error code explanation: HTTPStatus.FORBIDDEN - Request forbidden -- authorization will not help."
我该如何解决?
以下是我尝试重现问题的步骤:
# app.py
print("Content-type: text/html")
print()
print("<h1>Hello world!</h1>")
- 在
cgi-bin
目录中创建了文件app.py
- 使用命令 运行 http.server 和 cgi
python -m http.server --bind localhost --cgi 8000
我尝试访问路径 "http:localhost/cgi-bin/"
得到 错误 403
现在是 解析 部分,即在浏览器中打开 link。
我运行命令:
python -mwebbrowser http://localhost:8000/cgi-bin/app.py
一段时间后它给了我结果,我也能够访问第 2 步的 link。
希望对你有所帮助。
结果: