Skip to content

Commit

Permalink
elasticsearch configured.
Browse files Browse the repository at this point in the history
  • Loading branch information
nimaafshar79 committed May 29, 2020
1 parent 96ae36c commit fce5db1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ felan.txt
.vscode/
__pycache__
.DS_Store
DATABASE_CREDENTIALS.txt
DATABASE_CREDENTIALS.txt
create_elastic_index.ipynb
7 changes: 4 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
from calculator import calculator
from extentions import db, jwt, migrate, mail
from extentions import db, jwt, migrate, mail, elastic
from admin import admin
from users import users, models as user_models
from foods import foods, models as food_models
Expand Down Expand Up @@ -34,7 +34,8 @@ def temp_main_function():
'status': 'API is up and running:))',
'ENV': app.config['ENV'],
'DEBUG': app.config['DEBUG'],
'TESTING': app.config['TESTING']
'TESTING': app.config['TESTING'],
'elasticsearch_status': 'ready' if elastic.ping() else 'broken'
}

app.register_blueprint(calculator)
Expand All @@ -53,7 +54,7 @@ def temp_main_function():
if app.debug:
app.wsgi_app = DebuggedApplication(app.wsgi_app, evalex=True)

#enabling whitenoise
# enabling whitenoise
app.wsgi_app = WhiteNoise(app.wsgi_app)
for static_folder in app.config['STATIC_FOLDERS']:
app.wsgi_app.add_files(static_folder)
Expand Down
6 changes: 4 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ class Config(object):

# admin settings


#static file settings
# static file settings
STATIC_FOLDERS = (
'admin/static/',
'static/'
)

# elasticsearch settings
ELASTICSEARCH_URL = os.getenv('ELASTICSEARCH_URL')


class DevelopmentConfig(Config):
FLASK_DEBUG = True
Expand Down
5 changes: 3 additions & 2 deletions extentions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from flask_mail import Mail
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
from elasticsearch import Elasticsearch
from config import Config

db = SQLAlchemy()
migrate = Migrate(db=db)
jwt = JWTManager()
mail = Mail()


elastic = Elasticsearch(Config.ELASTICSEARCH_URL) if Config.ELASTICSEARCH_URL else None
Binary file modified requirements.txt
Binary file not shown.

0 comments on commit fce5db1

Please sign in to comment.