Start a static HTTP web server

Photo by Artem Sapegin on Unsplash

Did you know it’s easy to start an HTTP web server using some of your favorite programming languages?

Prerequisites

Create a directory with an HTML file:

mkdir static
cd static
echo "<h1>Hello, world!</h1>" > index.html

Python

Python 3:

python3 -m http.server

Python 2:

python -m SimpleHTTPServer

View your webpage at localhost:8000. To specify the port, pass the port number in the next argument:

python3 -m http.server 1337
python -m SimpleHTTPServer 1337

Node.js

http-server:

npm install --global http-server
http-server

Or:

npx http-server

View your webpage at localhost:8080. To specify the port, use the -p flag:

http-server -p 1337

Ruby

ruby -run -e httpd .

View your webpage at localhost:8080. To specify the port, use the -p flag:

ruby -run -e httpd . -p 1337

PHP

php -S localhost:8000

View your webpage at localhost:8000. To specify the port, replace the port number in the command:

php -S localhost:1337

--

--

--

remarkablemark.org

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

KYVE Stimulated Testnet: Corellia Mission -Testnet Explanation

Should we hire a developer?

Image of 6 post it notes, saying: Motivation? Salary? Sprints, tests, maintenance, Team? Development? Tech and kit?

How did I manage to create a smart contract in web3?

Git: Rewrite history and ways to use it effectively

⏰ WONO Presale - Renewal

DevOps with Puppet, Chef and Ansible

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
remarkablemark

remarkablemark

remarkablemark.org

More from Medium

Role of Full-Stack Developer in Web Development

Setup Mocha in watch mode for TDD in Node.js

Most important methods of Async.js npm module for Node.js

What is Node.js?