Appearance
FastAPI Server Example
This page embeds the full source for examples/fastapi_server.py.
python
"""Example: expose the generic JSON swarm transport over HTTP with FastAPI."""
import uvicorn
from swarmforge.api import create_fastapi_app
from swarmforge.env import get_env, get_env_int
app = create_fastapi_app()
if __name__ == "__main__":
uvicorn.run(
app,
host=get_env("SWARMFORGE_HOST", default="127.0.0.1") or "127.0.0.1",
port=get_env_int("SWARMFORGE_PORT", default=8000),
)Run:
bash
python examples/fastapi_server.py