1

I am working on a small education project which will use Python SimpleHTTPServer from a shell script to serve static files from a folder like this:

python -m SimpleHTTPServer

I am not sure on which platforms the project will be run.

I don't think users will run it in some exotic environments - generally OSX, Linux, Windows.

Will it be enough to write in docs that Python is required to run it?

3 Answers 3

4

No, this will not be sufficient in 2018, and even less so in the future. You should tell them to use python3 -m http.server, and that Python 3 is required, but with a note saying they can use SimpleHTTPServer from Python 2 if they have that instead—and probably mentioning than Mac users do already have Python 2 instead.

(I'd like to say that you can get away with ignoring Python 2 entirely, because anyone who chooses to use it ought to know what they're doing by this point, but thanks to OS X, you can't quite get away with that yet.)

  • Windows: Users who go to python.org to install Python will be presented with 3.6 as the first choice, and 2.7 as the second choice. And in a year and a half, 2.7 will likely be moved to the "old versions" page along with 3.5 and 2.6.
  • Mac: Python 2.7 comes preinstalled. If they go to python.org, or use Homebrew, they'll be presented with 3.6 as the default, but if they know that they already have Python, they won't try that. And Apple may well keep shipping 2.7 long beyond 2020.
  • Linux: Current versions of most distros have 3.x preinstalled, and some do not have 2.x. And in a year and a half, most of the big ones are planning on relegating 2.x to community-package status. However, there are plenty of people still using older "Long-Term Support" versions of their distros, and these will continue to support (and maybe pre-install) 2.7 until they go out of support, which ranges from 2-8 years from now.
Sign up to request clarification or add additional context in comments.

Comments

3

SimpleHTTPServer is only available on Python 2.x.

For 3.x you need to run it as python -m http.server.

Also, it might be worth mentioning that you can add port as an extra argument. (python -m http.server 1234 or python -m SimpleHTTPServer 1234)

Comments

-1

Referring to in in the documentation should be enough I guess.

Linux and OSX should come with python preinstalled. (As far as I know). For windows this isn't always the case. Some installations do, some don't.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.