Local HTTP test server CLI - echo, static files, mock APIs
Project description
httptest
Local HTTP test server CLI for development. Echo requests, serve static files, or mock APIs.
Installation
pip install httptest-cli
Quick Start
# Echo all requests back as JSON
httptest echo
# Serve static files
httptest static ./public
# Mock API from JSON spec
httptest mock api.json
# Record requests to file
httptest record -o requests.jsonl
# Replay recorded requests
httptest replay requests.jsonl -t http://localhost:3000
Commands
echo
Echo all incoming requests back as JSON. Useful for debugging webhooks or API clients.
httptest echo # Start on port 8080
httptest echo -p 3000 # Custom port
httptest echo -r requests.jsonl # Record all requests
Response format:
{
"timestamp": "2026-02-04T12:00:00.000Z",
"method": "POST",
"path": "/webhook",
"query": {"foo": ["bar"]},
"headers": {"Content-Type": "application/json", ...},
"body": {"event": "user.created"},
"client": {"address": "127.0.0.1", "port": 54321}
}
static
Serve static files from a directory with automatic index.html and directory listings.
httptest static ./public # Serve ./public directory
httptest static . -p 3000 # Current dir on port 3000
httptest static dist --index main.html # Custom index file
mock
Serve mock API responses from a JSON spec file.
httptest mock api.json
httptest mock spec.json -p 3000
Spec file format:
{
"GET /users": {
"body": [
{"id": 1, "name": "Alice"},
{"id": 2, "name": "Bob"}
]
},
"POST /users": {
"status": 201,
"body": {"id": 3, "message": "Created"}
},
"GET /slow": {
"body": {"status": "ok"},
"delay": 1000
},
"/health": {
"body": {"status": "healthy"}
},
"GET /users/*": {
"body": {"id": 1, "name": "User"}
}
}
Route keys:
"METHOD /path"- match specific HTTP method"/path"- match any method"/path/*"- wildcard matching
Response options:
bodyorresponse- response body (objects become JSON)status- HTTP status code (default: 200)headers- custom response headersdelay- response delay in milliseconds
record
Record all incoming requests to a JSONL file.
httptest record # Record to requests.jsonl
httptest record -o webhooks.jsonl
replay
Replay recorded requests against a target server.
httptest replay requests.jsonl -t http://localhost:3000
httptest replay webhooks.jsonl -t https://staging.api.com -d 100
Options:
-t, --target- Target URL base (required)-d, --delay- Delay between requests in ms--json- Output results as JSON
fixed
Return a fixed response for all requests.
httptest fixed # Returns "ok" with 200
httptest fixed --status 503 --body "maintenance"
httptest fixed --body '{"status":"healthy"}' --content-type application/json
Common Options
All server commands support:
-p, --port- Port to listen on (default: 8080)-H, --host- Host to bind to (default: 0.0.0.0)--no-cors- Disable CORS headers-q, --quiet- Suppress startup message
Use Cases
Webhook Development
Test webhooks locally by echoing requests:
httptest echo -p 9999 -r webhooks.jsonl
# Configure your service to send webhooks to http://localhost:9999
API Prototyping
Mock an API before it's built:
# api.json
{
"GET /api/users": {"body": [{"id": 1, "name": "Test"}]},
"POST /api/users": {"status": 201, "body": {"id": 2}},
"GET /api/users/*": {"body": {"id": 1, "name": "User"}}
}
httptest mock api.json -p 3001
Frontend Development
Serve your frontend build:
httptest static ./dist -p 8000
Load Testing Prep
Record production traffic, then replay against staging:
# Record
httptest record -p 8080 -o traffic.jsonl
# Replay
httptest replay traffic.jsonl -t http://staging.example.com
For AI Agents
See SKILL.md for agent-optimized documentation.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file httptest_cli-0.1.0.tar.gz.
File metadata
- Download URL: httptest_cli-0.1.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33f7b8e350824de84100b8262071aaadce23ec767cc4b5b0cdbac660eaa8f63b
|
|
| MD5 |
c9d9ef0de001d1d39fa56abc00d3a20c
|
|
| BLAKE2b-256 |
9bca5d76edc24327efdfd6dc5c23d2c4cb0b037bbc69094def12a4619473489e
|
File details
Details for the file httptest_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: httptest_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9f9c005abdac1c78aa64b937c9f4d28e714a1adc6ee325e7cdcf445f521b697
|
|
| MD5 |
ac2daa9dfce7482a4e7e8e69faad8f97
|
|
| BLAKE2b-256 |
0dc3d669bc8858dfcfacd4f8f764efc60dc5cea5a60e8212447e1bdfc39a0547
|