Search code examples
pythonhtmlserverpycharmpyscript

Cannot create local server HTTP port with python in Pycharm


I am trying to run the python .py file in PyScript. To do that, I need to load python file in a server because PyScript cannot access local file:

<py-script src="./greet.py"></py-script>

So I tried to create local server by entering this command in the terminal in the folder of my project:

python -m http.server

It has been over 30 minutes now and the server is not on. It shows that the terminal local is still running. It should take no more than a minute to be done. I have tried to locate specific port with: python -m http.server 80 but it still doesn't work. What should I do?


Solution

  • You might try also binding the server to a specific link-local IP address, using something like python -m http.server --bind 127.0.0.1 8000. The page should then appear at 127.0.0.1:8000.

    This was necessary for me on Windows - even after allowing Python permissions to access the network. Not sure if it's Windows-related, or Python not identifying the correct NIC to bind to, or what.