Skip to main content

Mock HTTP server

Project description

Turq is a small HTTP server that can be scripted in a Python-based language. Use it to set up mock HTTP resources that respond with the status, headers, and body of your choosing. Turq is designed for quick interactive testing, but can be used in automated scenarios as well.

Lets you do things like

“RESTful API” resource with cross-origin support:

if route('/v1/products/:product_id'):
    if GET or HEAD:
        json({'id': product_id, 'inStock': True})
    elif PUT:
        json(request.json)      # As if we saved it
    elif DELETE:
    cors()      # Handles preflight requests automatically

Redirect to an index.php, which serves a gzipped, cacheable page after 3 seconds of “loading”:

if path == '/':

if path == '/index.php':
    header('Cache-Control', 'max-age=3600')

Stream server-sent events:

header('Content-Type', 'text/event-stream')
for i in range(9000):
    chunk('data: event number %d\r\n\r\n' % i)

Built-in editor

You don’t even need to create any files, just use the built-in Web editor:


Get it now

In any Python 3.4+ environment:

$ pip3 install turq
$ turq

Read the docs for more.


BrowserStack have kindly provided a free subscription for testing Turq.

Project details

Download files

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

Files for turq, version 0.3.1
Filename, size File type Python version Upload date Hashes
Filename, size turq-0.3.1-py2.py3-none-any.whl (133.3 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size turq-0.3.1.tar.gz (213.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page