Skip to content

Getting started: a minimal Xpresso app

Start by making a file called and fill out the following code:

from xpresso import App, Path

async def endpoint():
    return {"message": "Hello World"}

app = App(routes=[Path(path="/", get=endpoint)])

What we've done here so far is:

  1. Create an endpoint function.
  2. Create a PathItem. A PathItem represents a unique HTTP resource, and can have several http methods attached to it.
  3. Bind our endpoint function to the PathItem's GET method.
  4. Create an App instance that uses the PathItem.

This is actually all we need, so you can run this using Uvicorn:

uvicorn main:app

Now navigate to http://localhost:8000/ and you should see {"message": "Hello World"} on your screen.

Interactive Swagger Docs

You can also navigate to http://localhost:8000/docs to see the OpenAPI docs, served via Swagger UI.


Swagger UI is a collection of HTML and scripts that serve as a frontend to an OpenAPI specification. Swagger gives you an interactive UI where you can send requests and get responses from your backend, all based on the OpenAPI specification that Xpresso automatically builds for you.

Since we didn't give Xpresso much info on the endpoint function's return value (it is implicitly None) and there is no request body, there isn't much information in OpenAPI. In later chapters, you will see how we can give Xpresso more information.