4 ms·
Is it really that hard to run `python -m http.server` in your repository?
by majewsky 7y ago
Is it really that hard to run `python -m http.server` in your repository?
- CaptainMarvel 7y agoFor someone getting started with programming? Very hard - it steepens the learning curve significantly
- ASalazarMX 7y agoThis. It's not only "open Notepad and save this text file, then open it in the browser". Leave the complexity of learning what Python is, the 2 vs 3 issue, 32/64 bit versions, appending locations to your path, CLI, etc., for when the user is ready to start with dynamic web pages.
- JetSpiegel 7y agoLuckly, the modern Python installers for Windows do all that.
- MrGilbert 7y agoWhy should I install Python, if I want to do a bit of JavaScript? That's not really the point. Of course it's not complicated to setup XAMPP, LAMPP or whatever.
- bildung 7y agoIf you run Linux, you won't have to install Python - it will be there by default in almost every distribution. It hink this is why GP chose this example - there's a multitude of other options to instantly start a web server. Edit: Here are 16 for example: https://gist.github.com/willurd/5720255 https://gist.github.com/willurd/5720255
- mort96 7y agoMost people are running Windows. That means most people trying to learn how to program are running Windows. I wouldn't want to figure out how to set up a web server on Windows myself, and absolutely wouldn't expect someone learning to program on their own to be able to art it up without getting frustrated. Even for people on Mac and Linux, having to start by learning the terminal is a pretty big and unnecessary obstacle to just getting to writing some JavaScript. Sure, you and I think it's easy, but it's a completely different paradigm which requires practice to get comfortable with. Even if you can be there right by someone learning to program, and help them set up a web server, they will have to remember how to do that when they want to play with programming while you're not there. That's actually quite a lot to remember when you don't yet understand what the commands mean; you think of it as "go to the directory, start SimpleHTTPServer", but they have to memorize the text they have to type. Maybe you're the one who cd'd into the correct folder for them, and they remember to type `python -M SimpleHTTPServer` in the terminal you created; they will then have problems they don't know how to solve when they go home and open a terminal and type the command and it doesn't work because they weren't in the correct directory.
- bildung 7y agoAbsolutely, I don't think we are in disagreement at all. I just wanted to mention the availability of simple web servers (on Linux, as you rightly state). On topic, I agree that this is throwing the baby out with the bathwater. A compromise would perhaps be an explicit whitelist of allowed directories to serve via the file:// protocol, set by the user (while disallowing traversal upwards of these, of course).
- maccard 7y agoUnless you're on a mac, or various Linux distros where python 2 is shipped by default still.
- rimliu 7y agoMac comes with PHP, so you can do php -S localhost:3000 -t ./
- maccard 7y agoAnd now you have: php -S localhost:3000 -t ./ on mac python -m http.server on some versions of linux, python -m SimpleHttpServer 8000 on others, and any of the above on windows. How is that easier than putting file://path/to/foo.html into my browser window, as someone getting started in web development?
- piotrkubisa 7y agoPlease note, python is not available out of the box on Windows machines as in macOS, most of Linux distros. Personally, as a person who used python in my programming job, I don't remember when for last time or even I have ever typed mentioned by you command to start a local server.
- jperry 7y ago>Please note, python is not available out of the box on Windows machines as in macOS, most of Linux distros. It (almost, kind of) is now, actually. Running python on a recent Windows 10 box without python installed will prompt you to install it. https://devblogs.microsoft.com/python/python-in-the-windows-10-may-2019-update/ https://devblogs.microsoft.com/python/python-in-the-windows-...
- adrianN 7y agoWhen I was about 13 I wanted to learn C++. I bought a book, installed the software from the CD and tried compiling the first example. It failed with a cryptic error about a file not being found. I gave up on programming for a number of years. The book had failed to mention that I need to include the compiler in my PATH.
- kspp 7y agoHonestly, if that's all that took you to give up on programming, it would not have gone on much longer anyway, especially with something like C++.
- adrianN 7y agoSo what was I supposed to do with no expert on hand and no Internet? I went back to the bookshop and asked there. They didn't know either, so I returned the book. I returned to programming when I learned about Quickbasic. That just worked and had an extensive help system that was suitable for self study.
- nmca 7y agoI don't think that's very fair. Some people are extremely gifted mathematicians with incredible talent for algorithmic thinking, yet can be totally shut down by build configuration bullshit. It's a huge pain point in C-land.
- singularity2001 7y agoEven worse, the code examples of (in)famous Bjarne Stroustrup were missing neccessary #include's and contained deadly typos.
- nemetroid 7y agoI started learning HTML at age eight. No one in my family had experience with programming or using a terminal (there was an HTML book on discount at the book store). I was able to get started because it was dead simple, and only used tools I was already familiar with: the web browser, Notepad, and regular files.
- jereze 7y agoI had exactly the same experience.
- hawski 7y agoAs much as I prefer the file protocol, an other option would be: $ busybox httpd -p 8080 -f -p for port (also possible to bind to specific IP: -p 127.0.0.1:8080), -f for foreground, also optional -h for served directory (default is .). But the difference between doing almost nothing, a double click once and then it stays there even between restarts, to giving a specific command in a terminal is monstrously huge.
- Fnoord 7y agoNo it is not, and it has been easy to run a webserver on Windows for ages (Apache, Roxen, IIS, OmniWEB, etc). However the barrier of entry is still higher than simply editing a .html file and loading it from the browser with file:// The question is, what is more important? Shouldn't this functionality be optional at the very least?