Python Logo

Python Web Server One-Liner

Python Web Server One-liner

Today we are going to take a look at running a Python3.x HTTP Server in a single line of code.

Once you are in your console run the following command.

$ mkdir ~/pyhttp && cd ~/pyhttp && echo "Hello, friend" > index.html && python3 -m http.server 8000

Great, now you have created a root directory, index page and started up the server using a one-liner. Let's check and make sure it is running, shall we?

$ curl -X GET "http://localhost:8000/"

Hello, friend

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.