Skip to content

gpasxalis/flask-blueprints-elasticsearch-template

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask with Blueprints + Elasticsearch basic template

This is a simple template for creating flask apps with elasticsearch support.

NOTE: Elasticsearch must be already installed in your system!

Initialization

Follow these steps to initialize your working environment.

Fork and clone repository

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!

Prepare the virtual environment (venv)

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 

Create folder with env vars

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!.

Running the test server

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 35.8%
  • CSS 33.9%
  • HTML 27.4%
  • JavaScript 2.9%