Reputation: 55
I am asking it because I write very simply app but IT DON'T WORK.
I wrote this command in terminal in the /dir
:
python3 -m http.server --cgi
My script is in dir/cgi-bin/hp.py and that code:
#!/usr/bin/env python3
print"Content-type: text/html"
print()
print"<h1>Hello world!</h1>"
This I saw in window of browser:
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."
How can I fix it?
Upvotes: 2
Views: 7728
Reputation: 7504
Here are the following steps which I tried to reproduce the problem:
# app.py
print("Content-type: text/html")
print()
print("<h1>Hello world!</h1>")
app.py
in cgi-bin
directorypython -m http.server --bind localhost --cgi 8000
I tried accessing the path "http:localhost/cgi-bin/"
got Error 403
Now the resolving part, which is opening the link in browser.
I ran the command:
python -mwebbrowser http://localhost:8000/cgi-bin/app.py
After the while it gave me the result, and I was able to access the link for the step 2 also.
I hope that helps you.
Result:
Upvotes: 2