![]() This extension also exposes a simple decorator to decorate flask routes with. route ( "/api/v1/users" ) def list_users (): return "user example" Route specific CORS via decorator app = Flask ( _name_ ) cors = CORS ( app, resources = ). See the full list of options in the documentation. route ( "/" ) def helloWorld (): return "Hello, cross-origin-world!" Resource specific CORSĪlternatively, you can specify CORS options on a resource and origin level of granularity by passing a dictionary as the resources option, mapping paths to a set of options. from flask import Flask from flask_cors import CORS app = Flask ( _name_ ) CORS ( app ). In the simplest case, initialize the Flask-Cors extension with default arguments in order to allow CORS for all domains on all routes. The package also contains a decorator, for those who prefer this approach. It allows parameterization of all CORS headers on a per-resource level. ![]() This package exposes a Flask extension which by default enables CORS support on all routes, for all origins and methods. Install the extension with using pip, or easy_install. ![]() Please see the documentation for how to enable credential’ed requests, and please make sure you add some sort of CSRF protection before doing so! Installation This means no mucking around with different allowed headers, methods, etc.īy default, submission of cookies across domains is disabled due to the security implications. This package has a simple philosophy: when you want to enable CORS, you wish to enable it for all use cases on a domain. A Flask extension for handling Cross Origin Resource Sharing (CORS), making cross-origin AJAX possible.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |