Skip to main content

Micro HTTP library for Python.

Project description

🍵 Tea

Micro HTTP library for Python.

The 418 I am a teapot code comes true.

Developer Note: Flask is very popular web framework for Python and it may be one of the most used. So I thought in some places comparing Tea and Flask is a good idea. At the same time, Tea has Express.js-like syntax (which is web framework for JavaScript) with it's callback function syntax, Request, Response and URL objects. Also got a lot of reference from FastAPI too.

We can say this micro library is like their mix, to be different. It is just a "HTTP library" instead of "web framework" or "web library" because no need to exaggerate it.

Quick Start

$ pip install tea-web

Hello, World!

Simple Hello, World! example in Tea and equivalents in Flask and Express.js. See /examples for more example.

Tea

# app.py
from tea import Tea
app = Tea()
def handle_index(req, res):
    res.send("Hello, World!")
app.get("/", handle_index)
app.listen(port=8080)

Flask

# app.py
from flask import Flask
app = Flask(__name__)
@app.route("/", methods=["GET"])
def handle_index():
    return "Hello, World!"
app.run(port=8080)

Express.js

// app.js
import express from "express";
const app = express();
app.get("/", (req, res) => {
    res.send("Hello, World!");
});
app.listen(8080);

Advantages of Tea

  • Lightweight. No external requirement and the package cost is only ~7 KB.
  • More control over the Request, Response and URL objects. This objects can be used outside the library structure.
  • Easy to use and helpful on handling simple HTTP requests.

Disadvantages of Tea

  • Limited features and methods.
  • No template engine like Flask.
  • Callback function syntax is not really Pythonic without decorators. (Done on purpose but true.)
  • Not sure if it's ready for production.

Documentation

License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tea-web-0.3.1.tar.gz (8.6 kB view hashes)

Uploaded Source

Built Distribution

tea_web-0.3.1-py3-none-any.whl (8.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page