Serve a Directory via Python
Sometimes I'm working with a test HTML file and some JavaScript but need to work off of a served space. In that case, I sometimes need to swap out folders within MAMP Stack which leads to a maintenance nightmare. Bleh.
I recently found out that you can serve up a directory using one Python command line directive:
# Serves the current directory at: http://0.0.0.0:8000/
python -m SimpleHTTPServer
Excellent. No more directory and MAMP Stack juggling. Even better is that the command is easy to memorize so no need to constantly look it up. Keep this in mind when you want to work on something without a big server install!
CSS animations are right up there with sliced bread. CSS animations are efficient because they can be hardware accelerated, they require no JavaScript overhead, and they are composed of very little CSS code. Quite often we add CSS transforms to elements via CSS during...
While synchronous code is easier to follow and debug, async is generally better for performance and flexibility. Why "hold up the show" when you can trigger numerous requests at once and then handle them when each is ready? Promises are becoming a big part of the JavaScript world...
One of the most used JavaScript widgets over the past decade has been the text box autocomplete widget. Every JavaScript framework has their own autocomplete widget and many of them have become quite advanced. Much like the placeholder attribute's introduction to markup, a frequently used...
There's nothing like a subtle, slick website widget that effectively uses CSS and JavaScript to enhance the user experience. Of course widgets like that take many hours to perfect, but it doesn't take long for that effort to be rewarded with above-average user retention and...
https://www.npmjs.com/package/http-server
That’s even easier.
Nice!
Python comes preinstalled on number of OS’s though.
Python 3 has a different syntax too.
I think it’s
Except this only works under Python 2. The Python 3 command is slightly different.
Ever seen Fenix Web Server? I’m totally bias (I’m the author), but I think it works well :-) Has a GUI and a CLI, persistent servers, and an SSH tunneling tool for securely and temporarily sharing with others.
You can also do this very easily with php: