Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A stupidly simple python server that allows you to test client code before you have a server that actually works
branch: master

Merge pull request #4 from asandwhich/patch-1

Change FILE_PREFIX so paths are relative
latest commit c6f2165b45
@mathisonian authored
Failed to load latest commit information. Update Change FILE_PREFIX so paths are relative


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 --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 for more details.

Something went wrong with that request. Please try again.