Skip to main content

A mini mock server for http requests

Project description

Mini Mock Server

A mini mock server for http requests.

Features

  • Start an HTTP mock server without installing any web framework.
  • Delay requests to simulate slow endpoints using the response.sleep attribute.
  • Return random responses on the same route to simulate different kind of responses.

Important Notices

Currently, the mini-mock-server uses the http.server to start a new server, which is not recommended for production environments. The http.server only implements basic security checks. See the official documentation for more information.

Installation

pip install mini-mock-server

Usage

  1. Create a mock-api.json file for route specifications.
{
    "/": [
        {
            "url": "/users",
            "method": "GET",
            "response": [
                {
                    "status_code": 200,
                    "body": [
                        {"id": 1, "name": "Mario"},
                        {"id": 2, "name": "Luigi"}
                    ]
                },
                {
                    "sleep": 1,
                    "status_code": 400,
                    "body": {"error": "Bad request custom message"}
                }
            ]
        }
    ],
    "/api": [
        {
            "url": "/products/:id",
            "method": "GET",
            "response": {
                "status_code": 200,
                "body": {
                    "id": 1,
                    "name": "Product 001",
                    "price": 115.51
                }
            }
        }
    ]
}
  1. Start the mock server.
mini-mock-server mock-api.json

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mini_mock_server-0.0.27-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file mini_mock_server-0.0.27-py3-none-any.whl.

File metadata

File hashes

Hashes for mini_mock_server-0.0.27-py3-none-any.whl
Algorithm Hash digest
SHA256 0fc78195c6b7b2c1decbdc04f10f2b88a1901b64c68f91101d2b3db620246ae1
MD5 07d147aa7dc777fd350fc8c1699503a4
BLAKE2b-256 193282163f3671f871d55b9ed6505bfa67caea5e222a0ed2592d45a98ab1114d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page