Skip to main content
## What is it?

Silly Server can help you to mock some HTTP services which are not implemented yet, but you are really want to use them NOW.

It can mock GET, POST, PUT, DELETE and some more rarely used HTTP methods.

## How?

Mocking service is as simple as creating directory and few files within it just like that:

somedir/
GET # response content for GET /
GET_H # status and headers for GET /
other_dir/
GET # response content for GET /other_dir
POST # response content for POST /other_dir
POST_H # status and headers for POST /other_dir

And then running silly server:

./ss.py -d /path/to/somedir

Ready! It will be listening on port 8000 *(can be changed with -p option)* and wait for your HTTP requests.
You can do:

$ curl localhost:8000
% whatever you put into somedir/GET file %

$ curl -d "postparam=value&pararam=25" -X POST "localhost:8000/other_dir?someparam=value"
% somedir/other_dir/POST content%

Meanwhile in terminal where you launched ss.py some logs will appear:

localhost - - [19/Oct/2012 13:23:03] "POST /other_dir?someparam=value HTTP/1.1" 200 -

Got some GET params here:
someparam: ['value']

Got some payload:
postparam: ['value']
pararam: ['25']

You can specify response status and headers within GET\_H, POST\_H, %yourmethod%\_H files. Format is simple:

403
content-type: text/html
cool-header: i'm cool

So, first line is status code, other lines are headers.

## Check example!

Following urls are mocked:

GET / # 400 Bad Request.
GET /user # 200. Returns json with users list.
GET /user/john/status # 200. Returns json with John's status.
GET /user/anonymous/status # 403. You can't see this.
POST /user # 200. Returns some json.

Any other requests will return default response.

Check it out:

% ./ss.py -d example

# go to other terminal

% curl -X GET -v localhost:8000
< HTTP/1.0 400 Bad Request
< cool-header: OLOLO
<
Your request was very bad.


% curl -X GET -v localhost:8000/user/
< HTTP/1.0 200 OK
< whats-here: users list
<
{
"users": ["john", "anonymous"]
}


% curl -X GET -v localhost:8000/user/john/status
< HTTP/1.0 200 OK
<
{
"status": "drunk"
}


% curl -X GET -v localhost:8000/user/anonymous/status
< HTTP/1.0 403 Forbidden
<
You can't get status of anonymous, he is anonymous. lol.


% curl -X POST -d "param=value&other_param=25" localhost:8000/user
< HTTP/1.0 200 OK
< content-type: maybe some json is here
<
{
"whatsup": "You just posted something."
}


Have fun!

Metadata

Release files for silly-server 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for silly-server 0.2
File Size Uploaded Provenance Actions
silly-server-0.2.tar.gz 6.1 kB Without provenance Details for silly-server-0.2.tar.gz

Release files / silly-server-0.2.tar.gz

Download URL silly-server-0.2.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
75d62a6a5cbbbf715b3092cb170a48c9a3c1af91ffcd759288673ee3c8697b8f
BLAKE2b-256 checksum
How to use checksums
c227f3c8eff0e288f701028d32d1f341016abd6439e114564a91f2b1e72346cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for silly-server 0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page