Highlighted
Moderator
Moderator
  • 609 Views

Need a quick web server to serve content from the current directory?

You may have a an occassional need to setup a transient webserver (without installing any additional packages). 

This is really easy with Python.

Simply change to the directory from which you want to serve content, and run the following:

python -m SimpleHTTPServer 80

Be mindful that only privileged users can bind to privileged ports.

Labels (2)
2 Replies
Highlighted
  • 595 Views

Re: Need a quick web server to serve content from the current directory?

There's also

python3 -m http.server [port]

In case you prefer python 3 or want to avoid the shift key. 

Reply
Loading...
Highlighted
Moderator
Moderator
  • 593 Views

Re: Need a quick web server to serve content from the current directory?

Thanks @KevinMGranger!

Just to remind our users that the above will work with python3 installed, RHEL7 still ships with python2.

0 Kudos
Reply
Loading...
Join the discussion
You must log in to join this conversation.