0.0
The project is in a healthy, maintained state
A web server using Ruby's built-in TCPServer class & web sockets
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 5.2, >= 5.2.1
 Project Readme

Teapot 🫖

A minimal web server

Built with
Ruby

Gem Version Testing

Teapot was named from the HTTP error code "418 I'm a teapot".

NOTE: Teapot is not meant to be a replacement for more well known webservers! Teapot is lacking vital security features. The main goal for this project was for me to learn how web servers work!

Table of Contents

  • Teapot
    • Table of Contents
    • Getting started
    • Features
    • Examples
    • Unsupported features
    • Contributing

Getting started

# app.rb
require 'voffie_teapot'

server = VoffieTeapot.new()
port = 4567

server.get('/') do |req, res|
  res.body = 'hello world'
end

server.listen(port)

Install the gems needed:

gem install voffie_teapot

And run with:

ruby app.rb

This will spin up a server which can be accessed through http://localhost:4567

Features

To use Slim features make sure to have it installed:

gem install slim

Teapot supports different features such as:

  • Routing: GET and POST routes with support for route parameters.
  • Middleware: Make changes to the request or response before the route handler.
  • Slim Templating: Render Slim templates with layout support.
  • Static Files: Serve static files from the ./public directory.

Examples

The available examples are:

  • Cookies: Set and read cookies in your application.
  • HTML: Serve and render static HTML files.
  • Redirect: Redirect users to another path.
  • Route params: Handle dynamic routes and access route parameters.
  • Slim: Use Slim template to render dynamic content.

All examples can be found here

Unsupported Features

Since this project was meant as a learning experience, certain features are not available. Some of these are:

  • Multiple HTTP method support: Currently only GET & POST are supported. Next methods to be supported would be PUT & DELETE.
  • Security: Teapot does not have any rate limiting built in or other security meassures.

Contributing

As mentioned at the top, this project was meant to be a learning experience for me. However I appreciate and welcome anyone that wants to submit changes!