From c6a3588e3374c3a66b5a737934a1684dc6a4352b Mon Sep 17 00:00:00 2001 From: Inex Code Date: Fri, 24 Jun 2022 20:25:49 +0300 Subject: [PATCH] add CORS --- selfprivacy_api/app.py | 2 ++ shell.nix | 26 ++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/selfprivacy_api/app.py b/selfprivacy_api/app.py index 082ddee..5c21111 100644 --- a/selfprivacy_api/app.py +++ b/selfprivacy_api/app.py @@ -8,6 +8,7 @@ from flask import Flask, request, jsonify from flask_restful import Api from flask_swagger import swagger from flask_swagger_ui import get_swaggerui_blueprint +from flask_cors import CORS from strawberry.flask.views import AsyncGraphQLView @@ -34,6 +35,7 @@ def create_app(test_config=None): """Initiate Flask app and bind routes""" app = Flask(__name__) api = Api(app) + CORS(app) if test_config is None: app.config["ENABLE_SWAGGER"] = os.environ.get("ENABLE_SWAGGER", "0") diff --git a/shell.nix b/shell.nix index 947af0b..2735de1 100644 --- a/shell.nix +++ b/shell.nix @@ -1,23 +1,24 @@ { pkgs ? import {} }: let sp-python = pkgs.python39.withPackages (p: with p; [ - flask - flask-restful - setuptools - portalocker - flask-swagger - flask-swagger-ui - pytz - pytest - pytest-mock - pytest-datadir - huey + flask + flask-restful + setuptools + portalocker + flask-swagger + flask-swagger-ui + pytz + pytest + pytest-mock + pytest-datadir + huey gevent mnemonic coverage pylint pydantic typing-extensions + flask-cors (buildPythonPackage rec { pname = "strawberry-graphql"; version = "0.114.5"; @@ -34,6 +35,7 @@ let pydantic pygments poetry + flask-cors ]; src = fetchPypi { inherit pname version; @@ -51,4 +53,4 @@ pkgs.mkShell { PYTHONPATH=${sp-python}/${sp-python.sitePackages} # maybe set more env-vars ''; -} \ No newline at end of file +}