Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vfaronov/turq
Mock HTTP server
https://github.com/vfaronov/turq
api debug http mock rest server testing
Last synced: 3 months ago
JSON representation
Mock HTTP server
- Host: GitHub
- URL: https://github.com/vfaronov/turq
- Owner: vfaronov
- License: isc
- Archived: true
- Created: 2012-11-17T16:05:29.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2018-12-22T17:43:52.000Z (almost 6 years ago)
- Last Synced: 2024-07-20T03:53:35.234Z (4 months ago)
- Topics: api, debug, http, mock, rest, server, testing
- Language: Python
- Homepage:
- Size: 365 KB
- Stars: 68
- Watchers: 6
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE
Awesome Lists containing this project
README
Turq
====.. warning::
Turq is no longer maintained nor used by its author.
Try `mitmproxy`__ with `scripting`__ instead.
See also https://gist.github.com/vfaronov/3f7848932ed96a264c382902262ce7b3__ https://mitmproxy.org/
__ https://docs.mitmproxy.org/stable/addons-scripting/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 automaticallyRedirect 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).. _server-sent events: https://en.wikipedia.org/wiki/Server-sent_events
Built-in editor
---------------You don't even need to create any files, just use the built-in Web editor:
.. image:: 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.
.. _BrowserStack: https://www.browserstack.com/