Python JavaScript CSS Smarty
Switch branches/tags
Latest commit c060338 Apr 5, 2017 @vfaronov Update manifest
Permalink
Failed to load latest commit information.
docs Assorted documentation improvements Apr 5, 2017
tests Tweak tests Apr 4, 2017
tools Tweak packaging, basic Travis setup Apr 4, 2017
turq --version Apr 4, 2017
.gitignore Beginnings of examples and test suite Mar 26, 2017
.travis.yml
CHANGELOG.rst Version 0.3.1 Apr 4, 2017
HACKING.rst Basic developer documentation Apr 5, 2017
LICENSE Remove everything for the upcoming overhaul Mar 21, 2017
MANIFEST.in Update manifest Apr 5, 2017
README.rst Assorted documentation improvements Apr 5, 2017
appveyor.yml
pylintrc Fix Pylint generated-members regexp Mar 25, 2017
screenshot.png Screenshot with slightly less menacing fonts Apr 4, 2017
setup.cfg Basic scaffolding Mar 21, 2017
setup.py Assorted documentation improvements Apr 5, 2017

README.rst

Turq

https://img.shields.io/pypi/v/turq.svg? https://img.shields.io/pypi/pyversions/turq.svg? https://readthedocs.org/projects/turq/badge/?version=latest https://travis-ci.org/vfaronov/turq.svg?branch=master https://ci.appveyor.com/api/projects/status/srfa9mlgafe63o6d?svg=true

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:
        status(204)
    cors()      # Handles preflight requests automatically

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

if path == '/':
    redirect('/index.php')

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

Stream server-sent events:

header('Content-Type', 'text/event-stream')
for i in range(9000):
    sleep(1)
    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:

screenshot.png

Get it now

In any Python 3.4+ environment:

$ pip3 install turq
$ turq

Read the docs for more.

Thanks

BrowserStack have kindly provided a free subscription for testing Turq.