Teapot 🫖
A minimal web server
Built with
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_teapotAnd run with:
ruby app.rbThis 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 slimTeapot supports different features such as:
-
Routing:
GETandPOSTroutes 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
./publicdirectory.
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&POSTare supported. Next methods to be supported would bePUT&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!