CORS plugin for Bottle framework
Project description
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)
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
bottle-cors-0.1.4.tar.gz
(2.9 kB
view hashes)
Built Distribution
Close
Hashes for bottle_cors-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93953a13878956e6585b12f355859d039c30c9d5c9c2c9128c288590eba946e7 |
|
MD5 | dfd773a5f2076820474e3994466c856b |
|
BLAKE2b-256 | c204b5bddc6eff2d13aa58e5e2098f76934c0981bc10e3191daa3c46b207188a |