I have a question regarding a Python running problem. I set up a local server with the Windows command prompt using the python -m http.server 8000
command, but when I run my script on http://localhost:8000/cgi-bin/hello.py
, it just shows me the source code instead of actually running the script.
I use the code i found on this link.
#!/usr/bin/python
print('Content-Type: text/html')
print()
print('<html>')
print('<head><title>Hello from Python</title></head>')
print('<body>')
print('<h2>Hello from Python</h2>')
print('</body></html>')
I've seen several people having the same problem, but I couldn't really find a solution. I work with Python 3.5
You should follow the documentation . The command for Python 3 is:
python -m http.server --cgi 8000
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.