Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lucianoratamero/apistar_cors_hooks
Enables CORS on API Star apps via event hooks
https://github.com/lucianoratamero/apistar_cors_hooks
api apistar cors
Last synced: about 2 months ago
JSON representation
Enables CORS on API Star apps via event hooks
- Host: GitHub
- URL: https://github.com/lucianoratamero/apistar_cors_hooks
- Owner: lucianoratamero
- License: bsd-3-clause
- Created: 2018-04-21T00:47:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-04-21T01:26:11.000Z (over 6 years ago)
- Last Synced: 2024-08-08T21:31:21.285Z (5 months ago)
- Topics: api, apistar, cors
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
apistar_cors_hooks
==================.. image:: https://travis-ci.org/lucianoratamero/apistar_cors_hooks.svg?branch=master
:target: https://travis-ci.org/lucianoratamero/apistar_cors_hooksThis project enables CORS on `API Star`_\ apps via event hooks.
Suppports:
- apistar>=0.4.0
- python>=3.6Installation
~~~~~~~~~~~~Install via PyPI:
.. code:: shell
pip install apistar_cors_hooks
After installing, we need to add and instance of ``CORSRequestHooks`` to your ``event_hooks`` in your app:
.. code:: python
from apistar import App, Route
from apistar_cors_hooks import CORSRequestHooksdef homepage() -> str:
return 'Homepage
'routes = [
Route('/', method='GET', handler=homepage),
]event_hooks = [CORSRequestHooks()]
app = App(routes=routes, event_hooks=event_hooks)If you want to customize WSGICORS options, you just need to pass a dict via the ``options`` kwarg:
.. code:: python
custom_options = {"origin": "your_host_server"}
event_hooks = [CORSRequestHooks(options=custom_options)]
app = App(routes=routes, event_hooks=event_hooks)Contributing
~~~~~~~~~~~~Since I'm a WSGI/CORS noob, I may have left a bug or two, or didn't think of better ways to implement this.
Be free to open an issue, contribute with PRs and contact me at ``[email protected]``.
.. _API Star: https://github.com/encode/apistar
Changelog
~~~~~~~~~~~~0.1.1
'''''
- adds README.rst as long description on PyPI0.1.0
'''''
- initial version