A collection of RESTful APIs for interacting with elastic-cluster, written and tested using Python and Flask.
A collection of RESTful API’s, written and tested using the Flask
framework of Python
language, for interacting with the Elastic-cluster
without breaking any security protocol or exposing any credentials/access tokens/confidential data.
csv
or json
type.Kibana
dashboard for the data that is insertedpython --version
should be >=3
and <=3.10
Star and Fork the repository. Download or clone
# clone the repository
$ git clone https://github.com/atanughosh01/elasticsearch-api
$ cd elasticsearch-api
Create a virtualenv and activate it
$ python3 -m venv venv
$ . venv/bin/activate
Or on Windows cmd
$ py -3 -m venv venv
$ venv\Scripts\activate.bat
Or on Windows powershell
$ python3 -m venv venv
$ & venv\Scripts\Activate.ps1
Install pip requirements
$ pip install -U -r requirements.txt
$ export FLASK_APP=api
$ export FLASK_ENV=development
$ flask run
Or on Windows cmd
> set -x FLASK_APP=api
> set -x FLASK_ENV=development
> flask run
Or on Windows powershell
> $env:FLASK_APP = "api"
> $env:FLASK_ENV = "development"
> flask run
Create a .flaskenv
in the root
directory with the following content
export FLASK_APP=api
export FLASK_ENV=development
Make sure that python-dotenv
is installed
$ pip install python-dotenv==0.20.0
Then execute flask run
on the terminal.
Open http://127.0.0.1:5000
in a browser.
Use Postman to test the collection of API’s.
root
directory..flaskenv
file exists, if not create itMake sure whether Docker
is running or not
$ docker version
$ docker images
Build the docker image with Dockerfile
$ docker build -t es-api:v0.0.1 .
Run the docker image
$ docker run --name ElasticAPI -p 5000:5000 -d es-api:v0.0.1
Check the status of the container
$ docker ps
Open localhost:5000
in a browser.
Use Postman to test the collection of API’s.