aboutsummaryrefslogtreecommitdiff
path: root/gn3/app.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-09-20 08:43:38 +0300
committerFrederick Muriuki Muriithi2021-09-20 08:43:38 +0300
commit8442204492a28153e995f3147e06c9758cd3bd28 (patch)
treee53d227c7059d2d5f9c3b4869eb3809bb7250739 /gn3/app.py
parentf5415f41d7f682771555e73f36ac4ee7ef51a1d3 (diff)
downloadgenenetwork3-8442204492a28153e995f3147e06c9758cd3bd28.tar.gz
Enable Cross-Origin Resource Sharing
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * gn3/api/heatmaps.py: Fix bugs in data parsing * gn3/app.py: enable CORS * gn3/settings.py: add flask-cors configurations * guix.scm: Add flask-cors dependency For easier testing of the heatmaps generation feature, this commit activates the cross-origin resource sharing for all "localhost" origins.
Diffstat (limited to 'gn3/app.py')
-rw-r--r--gn3/app.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/gn3/app.py b/gn3/app.py
index b4b08d0..6b4c57e 100644
--- a/gn3/app.py
+++ b/gn3/app.py
@@ -11,6 +11,7 @@ from gn3.api.heatmaps import heatmaps
from gn3.api.correlation import correlation
from gn3.api.data_entry import data_entry
+from flask_cors import CORS
def create_app(config: Union[Dict, str, None] = None) -> Flask:
"""Create a new flask object"""
@@ -18,6 +19,12 @@ def create_app(config: Union[Dict, str, None] = None) -> Flask:
# Load default configuration
app.config.from_object("gn3.settings")
+ CORS(
+ app,
+ origins=app.config["CORS_ORIGINS"],
+ allow_headers=app.config["CORS_HEADERS"],
+ supports_credentials=True, intercept_exceptions=False)
+
# Load environment configuration
if "GN3_CONF" in os.environ:
app.config.from_envvar('GN3_CONF')