I'm having issues trying to get my browser to execute Python files and display them to the user. I'm brand new to Python so I'm sure it's just a stupid mistake or something I'm not understanding correctly.
I've tried to find tutorials online but there are so many different ones I'm not sure which is the correct way or what I'm doing wrong.
I am currently running Fedora 22 and have Python 3 installed. I have a directory on my desktop that looks like the following with the test.py being in the cgi-bin folder.
- PythonFiles
- cgi-bin
- test.py
- cgi-bin
I then run python3 -m http.server
from the PythonFiles directory so that it starts the server in that location.
However, when I navigate to localhost:8000
in my browser it just prints out the content/code of the python file. I have given the file permissions of 755
but that still doesn't work.
This is what my Python file looks like:
#!/usr/bin/env python3
print("Content-Type: text/plain;charset=utf-8")
print()
print(
"""
<html>
<body>
<h2>Python mde this</h2>
</body>
</html>
"""
)
I know there's something I'm missing but I can't seem to figure out what I'm doing wrong. Thanks for any help!