This is a simple template for creating flask apps with elasticsearch support.
NOTE: Elasticsearch must be already installed in your system!
Follow these steps to initialize your working environment.
a) Fork this repository. This will allow you to work on your own repository. No pull request is needed.
b) Log into the development machine. Clone your forked repository there:
mkdir my-app
cd my-app
git clone <your-github-path> .
NOTE: <your-github-path>
must be replaced by the path to your own repository!
Initial step: python elasticsearch client version must match elasticsearch server's one! Inspect your installed server's version with curl -XGET 'http://localhost:9200'
and adjust requirements.txt
accordingly before proceeding. Check also https://elasticsearch-py.readthedocs.io/en/master/#compatibility.
At the project's root folder, enter the following commands at terminal:
virtualenv venv -p python3
. venv/bin/activate
pip install --upgrade pip
pip install --upgrade -r requirements.txt
In project's top folder create a new subfolder secrets
. This must not be put under version control! In this new folder create a file env_vars
with the following content:
export MY_APP_PORT=<your-assigned-port>
export MY_APP_PREFIX=/<your-assigned-prefix>
export FLASK_APP=myapp
NOTE: <your-assigned-port>
and <your-assigned-prefix>
must be replaced by the actual data provided to you!.
Before running the server you should activate venv (if not already active):
. venv/bin/activate
Enter the following commands to start the testing flask server (with reloading):
. secrets/env_vars
flask run --reload --host=0.0.0.0 --port $MY_APP_PORT