Skip to content

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages