An experiment on building an http server from scratch.
This is a simple HTTP server with minimal features (obviously non spec compliant), built with Ruby using the Socket class available in Ruby’s standard library.
To run the server locally, you're going to need:
Ruby, I'm running version 2.5.1p57
Clone the repo and cd to the working directory
git clone git@github.com:esteedqueen/simple-http-server.git
cd simple-http-serverStart the server
- On the default port
4000
bin/startOR
- Specify your preferred port using
-por-portflags
bin/start -p 3000
OR
bin/start -port 8000Test via curl or open in browser:
curl "127.0.0.1:4000/"
OR
open "127.0.0.1:4000/"Test via curl or open in browser:
curl "127.0.0.1:4000/hello.txt"
OR
open "127.0.0.1:4000/hello.txt"Test via curl or open in browser:
curl "127.0.0.1:4000/hello.rb"
OR
open "127.0.0.1:4000/hello.rb"Test via curl or open in browser:
curl "127.0.0.1:4000/set?name=Bolatito"
OR
open "127.0.0.1:4000/set?name=Bolatito"curl "127.0.0.1:4000/get?key=name"
OR
open "127.0.0.1:4000/get?key=name"Test via curl or open in browser:
curl "127.0.0.1:4000/hello.py"
OR
open "127.0.0.1:4000/hello.py"