Quick start
import { Aside, Steps } from ‘@astrojs/starlight/components’;
-
Install the framework and CLI
Terminal window pip install "dexpot[cli]" -
Define an application
Save this as
main.py:import msgspecfrom dexpot import Dexclass ItemIn(msgspec.Struct):name: strprice: floatclass ItemOut(msgspec.Struct):id: intname: strprice: floatapp = Dex()@app.get("/items/{item_id}", response=ItemOut)def get_item(item_id: int) -> ItemOut:return ItemOut(id=item_id, name=f"item-{item_id}", price=9.99)@app.post("/items", body=ItemIn, response=ItemOut)def create_item(item: ItemIn) -> tuple[int, ItemOut]:return 201, ItemOut(id=1, name=item.name, price=item.price) -
Serve it
Terminal window dexpot serve main:app --host 127.0.0.1 --port 8000 -
Call the real HTTP surface
Terminal window curl -s http://127.0.0.1:8000/items/7curl -s -X POST http://127.0.0.1:8000/items \-H 'Content-Type: application/json' \-d '{"name":"keyboard","price":79.0}'The responses are JSON:
{"id":7,"name":"item-7","price":9.99}{"id":1,"name":"keyboard","price":79.0}
You can also run the file directly:
if __name__ == "__main__": app.serve(host="127.0.0.1", port=8000)Continue with the route contract or see the runnable examples.