CORS support for API Star via event hooks.
Project description
This project enables CORS on API Star apps via event hooks.
Suppports:
apistar>=0.4.0
python>=3.6
Installation
Install via PyPI:
pip install apistar_cors_hooks
After installing, we need to add and instance of CORSRequestHooks to your event_hooks in your app:
from apistar import App, Route
from apistar_cors_hooks import CORSRequestHooks
def homepage() -> str:
return '<html><body><h1>Homepage</h1></body></html>'
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:
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 luciano@ratamero.com.
Changelog
0.1.1
adds README.rst as long description on PyPI
0.1.0
initial version
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for apistar_cors_hooks-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f675de38bc550b3238b8a5ece39b2caf32a29292eb10bd67d562a7dc847c8cbd |
|
MD5 | a244e1a34f4d1eacd54b418008a145dc |
|
BLAKE2b-256 | 3c998c89672b2338c04f685545f95712a304f54c7986d387ab676e8c72f04ac8 |