Skip to content Skip to sidebar Skip to footer

Python Http.server Command Gives "syntax Error"

I am trying to start http.server from the Python shell (Python 3.6.2). In the shell, I issue the following commands: import http.server import socketserver python -m http.server 8

Solution 1:

Because you're having trouble understanding what we mean in the comments; you need to run the command

python -m http.server 8000 --bind 127.0.0.1

from a bash (or similar) shell, NOT from the python IDLE interpreter. They do not mean the same thing. You would have to type the command python into your shell in order to get to you Python IDLE interpreter.

If you're in your python interpreter and would like to exit, press Ctrl+D to return to your bash (or similar) shell. Then, execute the command

python -m http.server 8000 --bind 127.0.0.1

and it should work.

You are right that the python documentation for httpserver could be made more clear but you should know that when you see a call to python it's almost certainly being made from a shell.

Post a Comment for "Python Http.server Command Gives "syntax Error""