What does it do?
Hug’s idea is that you should describe what your code does exactly once, and it should automatically become usable in several different ways — as a web API, as a command someone types in a terminal, and as regular importable Python code — without writing it three separate times. It’s like designing one universal remote instead of a separate one for the TV, the sound system, and the lights. That write-once, expose-everywhere philosophy was fairly unusual among Python API tools when Hug arrived.
See it in action
This code defines a single function that automatically becomes reachable over the web, replying with a greeting message when visited.
import hug
@hug.get("/hello")
def hello():
return {"message": "Hello, world!"}
Why would a non-developer care?
For a small team without spare engineering hours, avoiding duplicate work across a web interface and a command-line tool is a real, tangible time save — Hug was clearly built by someone who felt that duplication pain firsthand.
Real-world examples
Hug has found a niche among small teams and side projects that want an API and a command-line interface without maintaining two separate codebases for them. Without a tool built around that idea, teams typically end up writing near-duplicate logic for each interface, which then quietly drifts apart over time.
Who uses it
Small teams and individual developers who want to expose the same piece of logic as both a web API and a command-line tool without duplicating code.
How it compares to alternatives
Hug was originally built on top of the Falcon framework for its web layer, adding the multi-interface idea Falcon itself doesn’t attempt; it’s a much smaller, more niche tool than FastAPI, which has largely overtaken it in popularity.
Fun fact
Hug was created by Timothy Crosley, the same developer behind isort, a widely used tool that automatically alphabetizes Python import statements.