diff --git a/README.md b/README.md index ceef637543f726fd3a7964976fccb1f35e388481..08617a0ef39c8092a5de1262e35c7b67bd4d851f 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,14 @@ This project does depend on python packages. * [```pip install importlib```](https://pypi.org/project/importlib/) Optional (for python 2.*) ### Wikstraktor Server -If you want wikstraktor as a server, you need to install [flask](https://flask.palletsprojects.com/en/2.0.x/installation/), and best practice is to do so in a [virtual environment](https://docs.python.org/3/library/venv.html#module-venv). +If you want wikstraktor as a server, you need to install [flask](https://flask.palletsprojects.com/en/2.0.x/installation/) and [flask-cors](https://flask-cors.readthedocs.io/en/latest/), and best practice is to do so in a [virtual environment](https://docs.python.org/3/library/venv.html#module-venv). The following commands are extracted from the aforementionned documentation, it is probably more secure to click on the link and follow the modules documentation : ```bash python3 -m venv wikstraktorenv #create wikstraktorenv environment . wikstraktorenv/bin/activate #activate environment pip install Flask #install Flask +pip install -U flask-cors #install Flask cors ``` ## Use diff --git a/wikstraktor_server.py b/wikstraktor_server.py index 0aae88625206bc451e97ab428c705ee63e8928dd..3e63995082eb7eec9b609c4e8c1be5378370d72f 100755 --- a/wikstraktor_server.py +++ b/wikstraktor_server.py @@ -2,10 +2,13 @@ from flask import Flask #server from flask import request #to handle the different http requests from flask import Response #to reply (we could use jsonify as well but we handled it) +from flask_cors import CORS #to allow cross-origin requests from wikstraktor import Wikstraktor import wikstraktor_server_config as config app = Flask(__name__) +CORS(app) + @app.route('/', methods=['GET']) def index(): c = request.remote_addr