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.26-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for mini_mock_server-0.0.26-py3-none-any.whl
Algorithm Hash digest
SHA256 1c5ee212434e3f2f8a9df8859733024e3e214d88f2f454b974fa89b8ab2599c9
MD5 59b8c2b3614e29af8fe2ca13ab6e09d1
BLAKE2b-256 980886eab6bf8789cb7ab2e78f6205573a199904bc89dbc68e329c4c94281dd8

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