METADATA 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. Metadata-Version: 2.1
  2. Name: Flask-Cors
  3. Version: 4.0.1
  4. Summary: A Flask extension adding a decorator for CORS support
  5. Home-page: https://github.com/corydolphin/flask-cors
  6. Author: Cory Dolphin
  7. Author-email: corydolphin@gmail.com
  8. License: MIT
  9. Platform: any
  10. Classifier: Environment :: Web Environment
  11. Classifier: Intended Audience :: Developers
  12. Classifier: License :: OSI Approved :: MIT License
  13. Classifier: Operating System :: OS Independent
  14. Classifier: Programming Language :: Python
  15. Classifier: Programming Language :: Python :: 3.8
  16. Classifier: Programming Language :: Python :: 3.9
  17. Classifier: Programming Language :: Python :: 3.10
  18. Classifier: Programming Language :: Python :: 3.11
  19. Classifier: Programming Language :: Python :: 3.12
  20. Classifier: Programming Language :: Python :: Implementation :: CPython
  21. Classifier: Programming Language :: Python :: Implementation :: PyPy
  22. Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
  23. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  24. License-File: LICENSE
  25. Requires-Dist: Flask >=0.9
  26. Flask-CORS
  27. ==========
  28. |Build Status| |Latest Version| |Supported Python versions|
  29. |License|
  30. A Flask extension for handling Cross Origin Resource Sharing (CORS), making cross-origin AJAX possible.
  31. This package has a simple philosophy: when you want to enable CORS, you wish to enable it for all use cases on a domain.
  32. This means no mucking around with different allowed headers, methods, etc.
  33. By default, submission of cookies across domains is disabled due to the security implications.
  34. Please see the documentation for how to enable credential'ed requests, and please make sure you add some sort of `CSRF <http://en.wikipedia.org/wiki/Cross-site_request_forgery>`__ protection before doing so!
  35. Installation
  36. ------------
  37. Install the extension with using pip, or easy\_install.
  38. .. code:: bash
  39. $ pip install -U flask-cors
  40. Usage
  41. -----
  42. This package exposes a Flask extension which by default enables CORS support on all routes, for all origins and methods.
  43. It allows parameterization of all CORS headers on a per-resource level.
  44. The package also contains a decorator, for those who prefer this approach.
  45. Simple Usage
  46. ~~~~~~~~~~~~
  47. In the simplest case, initialize the Flask-Cors extension with default arguments in order to allow CORS for all domains on all routes.
  48. See the full list of options in the `documentation <https://flask-cors.corydolphin.com/en/latest/api.html#extension>`__.
  49. .. code:: python
  50. from flask import Flask
  51. from flask_cors import CORS
  52. app = Flask(__name__)
  53. CORS(app)
  54. @app.route("/")
  55. def helloWorld():
  56. return "Hello, cross-origin-world!"
  57. Resource specific CORS
  58. ^^^^^^^^^^^^^^^^^^^^^^
  59. Alternatively, 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.
  60. See the full list of options in the `documentation <https://flask-cors.corydolphin.com/en/latest/api.html#extension>`__.
  61. .. code:: python
  62. app = Flask(__name__)
  63. cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
  64. @app.route("/api/v1/users")
  65. def list_users():
  66. return "user example"
  67. Route specific CORS via decorator
  68. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  69. This extension also exposes a simple decorator to decorate flask routes with.
  70. Simply add ``@cross_origin()`` below a call to Flask's ``@app.route(..)`` to allow CORS on a given route.
  71. See the full list of options in the `decorator documentation <https://flask-cors.corydolphin.com/en/latest/api.html#decorator>`__.
  72. .. code:: python
  73. @app.route("/")
  74. @cross_origin()
  75. def helloWorld():
  76. return "Hello, cross-origin-world!"
  77. Documentation
  78. -------------
  79. For a full list of options, please see the full `documentation <https://flask-cors.corydolphin.com/en/latest/api.html>`__
  80. Troubleshooting
  81. ---------------
  82. If things aren't working as you expect, enable logging to help understand what is going on under the hood, and why.
  83. .. code:: python
  84. logging.getLogger('flask_cors').level = logging.DEBUG
  85. Tests
  86. -----
  87. A simple set of tests is included in ``test/``.
  88. To run, install nose, and simply invoke ``nosetests`` or ``python setup.py test`` to exercise the tests.
  89. If nosetests does not work for you, due to it no longer working with newer python versions.
  90. You can use pytest to run the tests instead.
  91. Contributing
  92. ------------
  93. Questions, comments or improvements?
  94. Please create an issue on `Github <https://github.com/corydolphin/flask-cors>`__, tweet at `@corydolphin <https://twitter.com/corydolphin>`__ or send me an email.
  95. I do my best to include every contribution proposed in any way that I can.
  96. Credits
  97. -------
  98. This Flask extension is based upon the `Decorator for the HTTP Access Control <https://web.archive.org/web/20190128010149/http://flask.pocoo.org/snippets/56/>`__ written by Armin Ronacher.
  99. .. |Build Status| image:: https://github.com/corydolphin/flask-cors/actions/workflows/unittests.yaml/badge.svg
  100. :target: https://travis-ci.org/corydolphin/flask-cors
  101. .. |Latest Version| image:: https://img.shields.io/pypi/v/Flask-Cors.svg
  102. :target: https://pypi.python.org/pypi/Flask-Cors/
  103. .. |Supported Python versions| image:: https://img.shields.io/pypi/pyversions/Flask-Cors.svg
  104. :target: https://img.shields.io/pypi/pyversions/Flask-Cors.svg
  105. .. |License| image:: http://img.shields.io/:license-mit-blue.svg
  106. :target: https://pypi.python.org/pypi/Flask-Cors/