METADATA 5.3 KB

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