A stupidly simple python server that allows you to test client code before you have a server that actually works
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
README.md Update README.md Jul 2, 2014
simple-testing-server.py Use CRLF instead of LF in headers (RFC2616) Feb 25, 2016



A stupidly simple python server that allows you to test client code before you have a server that actually works Allows you to test json responses with the proper headers built in, and also custom error codes.


So say you want to build some sort of app that connects to a client... great! But how are you going to deal with separating the development between the application logic and the backend api? Where are your api calls supposed to go before that server exists? Enter this project.

Example Usage

Start by spinning up the server using

python simple-testing-server.py --port <PORT>


This server uses json as the default object structe. Say you want to get an example json response from your server. Suppose you're modeling some data in your app. Let's call an example model events. Then

GET http://localhost:<PORT>/events

will return to you the contents of a file called events.json with proper headers. This file is up to you to create and place in the same folder as the python script.

More generally, GET http://localhost:<PORT>/<model_name> will return an application/json response with content taken from a file called <model_name>.json placed in the same folder as the script. BYO example json files. (use the --path options if these files are in a different directory)


To make a post request with a successfull (200) response:

POST http://localhost:<PORT>/success

Want a failure (500)? Try

POST http://localhost:<PORT>/error

Those two response codes aren't good enough for you? Fine.

POST http://localhost:<PORT>/<response_code>

The body accepts parameters in application/x-www-form-urlencoded format.

Set Content-Type to application/x-www-form-urlencoded

POST http://localhost:<PORT>/any_url

The result is parsed and returned back as JSON


There you have it.


A list of command line options:

  • -h, --help - show a help message
  • -p <PORT>, --port <PORT> - run on a custom port
  • --path <PATH> - keep your sample data in a custom path


AFAIK all versions of python. If you don't have argparse installed, the custom port won't work and it will just default to PORT=8003 every time.



This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the WTFPL, Version 2, as published by Sam Hocevar. See http://sam.zoy.org/wtfpl/ for more details.