Quick and dirty server
I often find myself working on proof of concepts that consist of (at most) an index.html
, style.css
, and index.js
.
It always seems overkill to have some kind of "local server" plugin imported into the project - especially because I use a MacBook Pro and it has Python installed by default.
A neat little trick for serving a static site without additional dependencies is this…
- Navigate to the folder you want to serve
python -m SimpleHTTPServer
- Open
http://localhost:8000
What if PORT 8000 is in use?
Pass a different port number like this: python -m SimpleHTTPServer %%PORT_NUMBER%%
If you want it to be even simpler - stick this somewhere in your bash config!
srv() {
python -m SimpleHTTPServer
}
It doesn't come with any of the fancy stuff that other "local server" plugins might come with like hot reloading or compiling Scss but, if all you want is a small static site launching, why reach for another dependency?
Fin
Cover image courtesy of David Clode.
onward-journeys module
Real. Simple. Syndication.
Get my latest content in your favorite RSS reader.
I use InoReader but you don't have to.
Comments
In almost all cases, the comments section is a vile cesspool of Reply Guys, racists, and bots.
I don't want to have to deal with that kind of hell so I don't have a comments section.
If you want to continue the conversation, you can always hit me up on Mastodon (which is not a vile cesspool of Reply Guys, racists, and bots).