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:
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.
Metadata
Release files for turq 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| turq-0.3.1.tar.gz | 213.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| turq-0.3.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 346.6 kB
Release files / turq-0.3.1.tar.gz
| Download URL | turq-0.3.1.tar.gz |
|---|---|
| Size | 213.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4db8747eedaa4928618dd18376a80550f37a2a3823495934eef234e84c17fcfe
|
|
BLAKE2b-256 checksum How to use checksums |
f0752a942041a5e098a1580089b78fb90ebbbf79d4d883a25139ca2c3941574b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / turq-0.3.1-py2.py3-none-any.whl
| Download URL | turq-0.3.1-py2.py3-none-any.whl |
|---|---|
| Size | 133.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f83f1ee7c61bb5d74b6feb2c417aca3a0bb15954a9409c733432ce0d858ec95a
|
|
BLAKE2b-256 checksum How to use checksums |
a03b26e887df04d75bef9c6f6ad12c25e77a753e1bfd946e9628d3a542db40ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |