Web Frameworks & APIs

bottle

An entire web framework small enough to fit inside a single file.

Install it: pip install bottle

What does it do?

Bottle squeezes a working web framework into one Python file with zero required dependencies beyond Python itself — a pocket knife that still manages to do everything a toolbox does. You can copy that one file into any project and immediately start building a small website or API. It handles the basics: routing web addresses to your code, reading form data, and serving simple pages. There’s no database layer or authentication system included, deliberately, because Bottle is meant to stay tiny.

See it in action

This code creates a one-page website that displays “Hello, world!” and starts it running, all from a single short file.

from bottle import route, run

@route("/")
def home():
    return "Hello, world!"

run(host="localhost", port=8080)

Why would a non-developer care?

For anyone who just needs a quick working webpage for a school project, a small business tool, or a proof of concept, Bottle removes the setup headache entirely. Not every idea needs an enterprise-grade framework, and forcing a small one through a heavy one wastes real time.

Real-world examples

Bottle is popular in teaching environments and hobby projects because a beginner can read the entire framework’s source code in an afternoon and actually understand how a web framework works underneath. Its small footprint also makes it handy for embedding a lightweight web interface into other tools, like a local dashboard for a piece of hardware.

Who uses it

Hobbyists, educators teaching how web frameworks work, and developers who need to embed a tiny web interface into another tool.

How it compares to alternatives

Bottle occupies an even smaller niche than Flask, which it predates in spirit — both are micro frameworks, but Bottle takes minimalism further by avoiding external dependencies altogether. If a project outgrows Bottle’s simplicity, teams typically graduate to Flask or Django.

Fun fact

Bottle’s entire framework lives in a single Python file, small enough that some developers have printed it out just to study it line by line and learn how web frameworks work.

New to Python and want to actually try libraries like this yourself?

Find a beginner-friendly course

Related libraries