A minimal project to manage “servers” using:
- FastAPI backend (in-memory CRUD)
- Typer CLI that calls the API via HTTP
- Clean, beginner-friendly code
- GitHub: https://github.com/d3vilal/-CLI-
- List all servers
- Get server details by ID
- Create a server
- Update a server (only the fields passed)
- Delete a server
- Python 3.10+
- FastAPI
- Uvicorn
- Typer
- requests
- dummy_api.py — FastAPI app exposing CRUD endpoints
- cli_app.py — Typer CLI that calls the API
git clone https://github.com/d3vilal/-CLI-.git
cd -CLI-python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS/Linux
source .venv/bin/activatepip install fastapi uvicorn typer requestsuvicorn dummy_api:app --reload- API base URL: http://127.0.0.1:8000
- Swagger docs: http://127.0.0.1:8000/docs
- ReDoc docs: http://127.0.0.1:8000/redoc
In another terminal (with the virtual environment activated):
python cli_app.py list
python cli_app.py info 1
python cli_app.py add --title "web" --team "dev" --cluster "mumbai" --plan "basic" --auto_increase_storage
python cli_app.py update 1 --title "web-updated" --plan "premium"
python cli_app.py delete 1- The CLI expects the API at http://127.0.0.1:8000.
- To change it, edit:
API = "http://127.0.0.1:8000" # in cli_app.py- GET http://127.0.0.1:8000/servers
- GET http://127.0.0.1:8000/servers/{server_id}
- POST http://127.0.0.1:8000/servers
- PUT http://127.0.0.1:8000/servers/{server_id}
- DELETE http://127.0.0.1:8000/servers/{server_id}
{
"id": 1,
"title": "main_server",
"team": "bird",
"cluster": "mumbai",
"plan": "basic",
"auto_increase_storage": false
}