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 [email protected]:esteedqueen/simple-http-server.git
cd simple-http-server
Start the server
- On the default port
4000
bin/start
OR
- Specify your preferred port using
-p
or-port
flags
bin/start -p 3000
OR
bin/start -port 8000
Test 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"