Skip to main content

Extension that provides an easy way to add dev-only shortcuts to your routes.

Project description

Logo

Main workflow status Current pyPI version Documentation home Package license Supported on python versions Any color you want

Project Description

This extension provides an easy and safe way to add dev-only shortcuts to routes in your flask application.

The main beneficiaries are microservices that need to be tested regularly in conjunction with their clients. If you need to assert working communication and basic integration in a sufficiently complex ecosystem, clients that can not freely chose how their requests are formed gain a lot from being able to receive predictable responses. By skipping over the details of how the microservice is implemented, which bugs and minor changes it experiences over time, testing basic API compatibility gets a lot more manageable.

Usage

You can add shortcuts to your route functions either individually with decorators, or in a single swoop once all routes have been defined. Both ways are functionally equivalent.

With decorators:

from flask import Flask
from flask_shortcut import Shortcut

app = Flask(__name__)
short = Shortcut(app)

app.route('/foo', methods=['GET'])
short.cut(('short_foo', 200))
def foo():
    return 'foo'

app.route('/bar', methods=['POST'])
short.cut({'{"name": "TestUser"}': ('short_bar', 200)})
def bar():
    return 'bar'

With a wire call

from flask import Flask
from flask_shortcut import Shortcut

app = Flask(__name__)

app.route('/foo', methods=['GET'])
def foo():
    return 'foo'

app.route('/bar', methods=['POST'])
def bar():
    return 'bar'

Shortcut(app).wire(
    {
         '/foo': ('short_foo', 200),
         '/bar': {'{"name": "TestUser"}': ('short_bar', 200)
    }
)

Project home on github.

Project details


Download files

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

Source Distribution

flask_shortcut-0.3.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

flask_shortcut-0.3.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file flask_shortcut-0.3.1.tar.gz.

File metadata

  • Download URL: flask_shortcut-0.3.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.6.10 Linux/5.0.0-1036-azure

File hashes

Hashes for flask_shortcut-0.3.1.tar.gz
Algorithm Hash digest
SHA256 3df373b943b4009b318879dad1080b1ed0e3bd57b358c7cd9d6b7a8a41e839d0
MD5 2816a9259522d3e0f5cf3942b3d89f65
BLAKE2b-256 f0d3417059052bd5aac7d18d875d870676f920a0afc781b4baf6a3813f050bef

See more details on using hashes here.

Provenance

File details

Details for the file flask_shortcut-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: flask_shortcut-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.6.10 Linux/5.0.0-1036-azure

File hashes

Hashes for flask_shortcut-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0fd6dcaadda8d93571c2c21368701d7810cae6db4a5b645a7414d3ce7278f882
MD5 f3b62371296590b51dc5c44e600c4da7
BLAKE2b-256 9370a623cf9e1d00012e58c219e61632d4379c9a2e8473cbe6ee1c5e52407ff8

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page