Skip to main content

bottle-cors

Simple plugin to easily enable CORS support in Bottle routes.

Example

from bottle import Bottle, request, run
from truckpad.bottle.cors import CorsPlugin, enable_cors

app = Bottle()

@app.get('/')
def index():
    """
    CORS is disabled for this route
    """
    return "cors is disabled here"

@enable_cors
@app.get('/endpoint_1')
def endpoint_1():
    """
    CORS is enabled for this route. 
    OPTIONS requests will be handled by the plugin itself
    """
    return "cors is enabled, OPTIONS handled by plugin"

@enable_cors
@app.route('/endpoint_2', method=['GET', 'POST', 'OPTIONS'])
def endpoint_2():
    """
    CORS is enabled for this route. 
    OPTIONS requests will be handled by *you*
    """
    if request.method == 'OPTIONS':
        # do something here?
        pass
    return "cors is enabled, OPTIONS handled by you!"

app.install(CorsPlugin(origins=['http://list.of.allowed.domains.com', 'https://another.domain.org']))

run(app)

Metadata

Release files for bottle-cors 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bottle-cors 0.1.5
File Size Uploaded
bottle-cors-0.1.5.tar.gz 2.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bottle-cors 0.1.5
File Interpreter ABI Platform
bottle_cors-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 6.5 kB

Release files / bottle-cors-0.1.5.tar.gz

Download URL bottle-cors-0.1.5.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7045cc3a02c727527c1947c55795c5bd8df25f3a27998389856a3c5d3e2f288a
BLAKE2b-256 checksum
How to use checksums
6ef48be34680a4d9ebcef15d55f607e5853c9ce27bb2b455852de09101cbfbbe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.9

Release files / bottle_cors-0.1.5-py3-none-any.whl

Download URL bottle_cors-0.1.5-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16b32f0bf4c0b5fa7ee4cba503e23ca9a35adb0f0b628b347e994ec807c69e32
BLAKE2b-256 checksum
How to use checksums
1320643010f78dbe390ba48ed55b4b13dc2c57e9f7db5adc745ba7f2be22a3eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page