Skip to main content

Mock HTTP server

Project description

Turq is a tool for semi-interactively testing and debugging HTTP clients. Somewhat like httpbin, but more interactive and flexible. Turq runs a small HTTP server that is scriptable in a Python-based DSL. It lets you quickly set up mock URLs that respond with the status, headers and body of your choosing.


Run this on a machine with Python 2.6 or 2.7:

$ pip install turq
$ python -m turq
Listening on port 13085
Try http://localhost:13085/+turq/

Open http://localhost:13085/+turq/ in your Web browser. You should see a text area. This is the Turq console. Enter this and click “Commit”:


Now open http://localhost:13085/ (without the +turq/) in another tab. You should see a plain-text greeting.


Redirect from root to an index.php, which returns a simple HTML page after 2 seconds of “loading”:


Imitate a JSON API with JSONP and cross-origin support:


Prompt for basic HTTP authentication, then serve up a page with some text (ignoring credentials):

with path('/secret') as r:

Imitate round-robin balancing between three backends, one of which is slow:

with path('/') as r:

Simulate an intermittent error:

with path() as r:
    r.maybe().status(502).text('Bad Gateway')

Serve XML from /product.xml, reflecting the passed id parameter:

    lambda req: '<product><id>%s</id></product>' % req.query['id']

For more, see the complete documentation.

Project details

Release history Release notifications

History Node


History Node


This version
History Node


History Node


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
turq-0.2.0.tar.gz (11.9 kB) Copy SHA256 hash SHA256 Source None Dec 8, 2012

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page