Skip to content
Snippets Groups Projects
Commit 01d2dc71 authored by Enzo Simonnet's avatar Enzo Simonnet
Browse files

update CORS

parent 8fc9cfc9
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment