Skip to content

Commit 7ca1593

Browse files
committed
replaced mongoengine with flask-mongoengoengine, enabled threaded development run
1 parent 6e2dabe commit 7ca1593

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

app/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
)
2121

2222

23+
from flask_mongoengine import MongoEngine
24+
db = MongoEngine(app)
25+
2326
@app.errorhandler(404)
2427
def not_found(error):
2528
return "Not found", 404

app/stories/models.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
from bson.objectid import ObjectId
2-
from mongoengine import connect as connect
32
from mongoengine.fields import ListField, SortedListField,\
43
EmbeddedDocumentListField, EmbeddedDocumentField,\
54
GenericEmbeddedDocumentField, ReferenceField,\
65
GenericReferenceField, EmbeddedDocument,\
76
ObjectIdField, StringField,\
87
BooleanField, Document
98

10-
from app import app
11-
12-
with app.app_context():
13-
connect(app.config["DB_NAME"],
14-
host=app.config["DB_HOST"])
15-
169

1710
def update_document(document, data_dict):
1811
"""

config.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
class Config(object):
55
DEBUG = False
6-
DB_NAME = "iky-ai"
7-
DB_HOST = "mongodb://127.0.0.1:27017/"
8-
DB_USERNAME = ""
9-
DB_PASSWORD = ""
6+
MONGODB_DB = "iky-ai"
7+
MONGODB_HOST = "127.0.0.1"
8+
MONGODB_PORT = 27017
9+
MONGODB_USERNAME = ""
10+
MONGODB_USERNAME = ""
1011

1112
# Intent Classifier model detials
1213
MODELS_DIR = "model_files"
@@ -21,9 +22,11 @@ class Development(Config):
2122

2223
class Production(Config):
2324
# MongoDB Database Details
24-
DB_HOST = "mongodb://mongodb:27017/"
25-
DB_USERNAME = ""
26-
DB_PASSWORD = ""
25+
MONGODB_DB = "iky-ai"
26+
MONGODB_HOST = "mongodb"
27+
MONGODB_PORT = 27017
28+
MONGODB_USERNAME = ""
29+
MONGODB_USERNAME = ""
2730

2831
# Web Server details
2932
WEB_SERVER_PORT = 8001

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ipaddress==1.0.19
77
Jinja2==2.10
88
JSON-log-formatter==0.2.0
99
mongoengine==0.15.0
10+
flask-mongoengine
1011
nltk==3.2.5
1112
scipy==0.19.1
1213
numpy==1.13.3

run.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import os
2-
31
from app import app
42

53
if __name__ == '__main__':
6-
app.run(host='0.0.0.0', port=8080, debug=True)
4+
app.run(host='0.0.0.0', port=8080, debug=True, threaded=True)

0 commit comments

Comments
 (0)