Run a basic web server locally.

A few years ago, at the Torbay Tech Jam I was shown a neat way to start up a really basic http web server using python3.

Using this method I decided to have a go, so that I could share this, as it is linked to this weeks Code Club tutorials.

Note: I am using Debian Linux for this.

So after creating a new directory for the server

mkdir http cd http

I created a new file index.html and added a few basic lines of html to this.

<html>
<body>
<h1>this is a test line</h1>
</body>
<html>

Then from the command line entered:

python3 -m http.server 8080

Note: 8080 is the port number, so you can use something different, the default for http is 80.

Then pointing my web browser at

127.0.0.1:8080

I am able to view the page in the web browser.

Hope this is useful, could be useful for testing out what you are learning with Freecodecamp if you don't want to create Repl for this.

#linux,#debian,#web,#server,#http,#testing

I can be contacted on Mastodon here.

cc-by logo

Licenced under Attribution 4.0 International (CC BY 4.0)

Get a free Repl.it online IDE account here Get an Overleaf account here, Online collaborative LaTeX Editor


MastodonPeertubeQoto sign up

#LookingForWork

Donate using Liberapay