I'm looking for a dead simple bin that I can launch up in the shell and have it serve the current directory (preferably not ..), with maybe a -p
for specifying port. As it should be a development server, it should by default allow connections from localhost only, maybe with an option to specify otherwise. The simpler, the better.
Not sure which tags to use here.
There is the Perl app App::HTTPThis or I have often used a tiny Mojolicious server to do this. See my blog post from a while back.
Make a file called say
server.pl
. Put this in it.Install Mojolicious:
curl get.mojolicio.us | sh
and then runmorbo server.pl
.Should work, and you can tweak the script if you need to.
Using Twisted Web:
--pidfile=
disables the PID file. Without it atwistd.pid
file will be created in the current directory. You can also use--pidfile ''
.For Node, there's
http-server
:Python has:
python -m http.server --bind 127.0.0.1 8080
python -m SimpleHTTPServer 8080
Note that Python 2 has no
--bind
option, so it will allow all connections (not just fromlocalhost
).or if you don't want to use the default port 8000
or if you want to allow connections from localhost only
See the docs.
The equivalent Python 2 commands are
There is no
--bind
option.See the Python 2 docs.
In case your server files do not change, once you have edited and saved them, type
refresh
in your python console. This will update the files, provided by the server with the most recent ones.