A lightweight, configurable HTTP mock server built with Flask that provides standardized responses to all incoming requests. Perfect for testing, development, and API simulation scenarios.
- 🚀 Universal Request Handling: Responds to all HTTP methods (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)
- 🔄 Configurable Responses: Customize response codes and headers
- 📝 Request Logging: Built-in logging system for request tracking
- 🔒 Security Headers: Automatic security headers for all responses
- 🗜️ Response Compression: Built-in compression support for efficient responses
- 🏥 Health Check Endpoint: Built-in
/monitors/isaliveendpoint for monitoring - ⚙️ Environment Configuration: Easy configuration through
.envfile
- Clone the repository:
git clone https://github.com/yourusername/http-mock.git
cd http-mock- Create and activate a virtual environment:
# Windows
python -m venv venv
.\venv\Scripts\activate
# Linux/MacOS
python3 -m venv venv
source venv/bin/activate- Install dependencies:
pip install -r requirements.txtThe server can be configured through a .env file. A default configuration will be created on first run with these settings:
HOST=127.0.0.1
PORT=8080
CONSOLE_PRINT=1
RESPONSE_STATUS_CODE=204- Start the server:
python app.py-
The server will start on the configured host and port (default: http://127.0.0.1:8080)
-
Send requests to any endpoint:
# Example requests
curl http://localhost:8080/any/path
curl -X POST http://localhost:8080/api/test
curl -X PUT http://localhost:8080/resource/1- Check server health:
curl http://localhost:8080/monitors/isalive- All requests receive a 204 No Content response by default
- Health check endpoint (
/monitors/isalive) returns "up" with 200 status - All responses include security headers:
- Cache-Control: no-cache, no-store, must-revalidate
- Pragma: no-cache
- Expires: 0
The project uses:
- Python 3.x
- Flask for the web framework
- Flask-Compress for response compression
- python-dotenv for configuration management
This project is licensed under the terms of the included LICENSE file.