How would you enable Cross-Origin Resource Sharing (CORS) in a Flask application?
- Add Access-Control-Allow-Origin header to each route manually.
- CORS is not applicable to Flask applications.
- Set CORS_ENABLED = True in the Flask app configuration.
- Use the @cross_origin decorator from the flask_cors extension.
To enable CORS in a Flask application, you typically use the @cross_origin decorator provided by the flask_cors extension. This allows you to control which origins are allowed to access your API.
Loading...
Related Quiz
- In Django, how would you extend the User model to include additional fields?
- Python's ____ allows classes to be created dynamically, at runtime.
- You have to visualize the frequency distribution of a categorical variable. Which type of plot would you prefer using Matplotlib?
- You are developing a RESTful API and need to ensure that sensitive user data is secure during transit. Which approach would you use to secure data transmission?
- How can you optimize the performance of static files (CSS, JS, Images) in a web application developed using Python frameworks?