forked from alfredfrancis/ai-chatbot-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added create_app for app factory, setup unit test module, removed bli…
…nker dependancy
- Loading branch information
1 parent
9949764
commit f042a81
Showing
13 changed files
with
84 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"frontend/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py": true, | ||
"frontend/node_modules/node-gyp/gyp/pylib/gyp/common_test.py": true, | ||
"frontend/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py": true, | ||
"frontend/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py": true, | ||
"frontend/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py": true, | ||
"frontend/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py": true, | ||
"frontend/node_modules/node-gyp/gyp/pylib/gyp/input_test.py": true, | ||
"tests/test_nlu.py::TestCase::test_function": true, | ||
"tests/test_nlu.py::test_function": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
- "3.6" | ||
install: | ||
- pip install -r requirements.txt | ||
script: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,55 @@ | ||
import os | ||
from blinker import Namespace | ||
from flask import Flask,send_from_directory | ||
from flask_cors import CORS | ||
from flask_mongoengine import MongoEngine | ||
|
||
APP_ROOT = os.path.dirname(os.path.abspath(__file__ + "../../")) | ||
|
||
app = Flask(__name__) | ||
db = MongoEngine() | ||
|
||
CORS(app) | ||
def create_app(env = 'Development'): | ||
app = Flask(__name__) | ||
CORS(app) | ||
# Configurations | ||
try: | ||
env = os.environ['APPLICATION_ENV'] | ||
except KeyError as e: | ||
app.logger.info('Unknown environment key, defaulting to Development') | ||
app.config.from_object('config.%s' % env) | ||
db.init_app(app) | ||
|
||
# Configurations | ||
try: | ||
env = os.environ['APPLICATION_ENV'] | ||
except KeyError as e: | ||
# logging.error('Unknown environment key, defaulting to Development') | ||
env = 'Development' | ||
from app.agents.controllers import bots | ||
from app.nlu.controllers import nlu | ||
from app.intents.controllers import intents | ||
from app.train.controllers import train | ||
from app.endpoint.controllers import endpoint | ||
from app.entities.controllers import entities_blueprint | ||
|
||
app.config.from_object('config.%s' % env) | ||
app.config.update( | ||
DEBUG=True, | ||
TESTING=True, | ||
TEMPLATES_AUTO_RELOAD=True) | ||
app.register_blueprint(nlu) | ||
app.register_blueprint(intents) | ||
app.register_blueprint(train) | ||
app.register_blueprint(endpoint) | ||
app.register_blueprint(bots) | ||
app.register_blueprint(entities_blueprint) | ||
|
||
db = MongoEngine(app) | ||
admin_panel_dist = os.path.join(APP_ROOT, 'frontend/dist/') | ||
|
||
my_signals = Namespace() | ||
@app.route('/<path:path>', methods=['GET']) | ||
def static_proxy(path): | ||
return send_from_directory(admin_panel_dist, path) | ||
|
||
from app.agents.controllers import bots | ||
from app.nlu.controllers import nlu | ||
from app.intents.controllers import intents | ||
from app.train.controllers import train | ||
from app.endpoint.controllers import endpoint | ||
from app.entities.controllers import entities_blueprint | ||
@app.route('/') | ||
def root(): | ||
print(admin_panel_dist) | ||
return send_from_directory(admin_panel_dist, 'index.html') | ||
|
||
@app.errorhandler(404) | ||
def not_found(error): | ||
return "Not found", 404 | ||
|
||
return app | ||
|
||
app.register_blueprint(nlu) | ||
app.register_blueprint(intents) | ||
app.register_blueprint(train) | ||
app.register_blueprint(endpoint) | ||
app.register_blueprint(bots) | ||
app.register_blueprint(entities_blueprint) | ||
|
||
admin_panel_dist = os.path.join(APP_ROOT, 'frontend/dist/') | ||
|
||
@app.route('/<path:path>', methods=['GET']) | ||
def static_proxy(path): | ||
return send_from_directory(admin_panel_dist, path) | ||
|
||
@app.route('/') | ||
def root(): | ||
print(admin_panel_dist) | ||
return send_from_directory(admin_panel_dist, 'index.html') | ||
|
||
@app.errorhandler(404) | ||
def not_found(error): | ||
return "Not found", 404 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from app import app | ||
|
||
from app import create_app | ||
app = create_app() | ||
if __name__ == '__main__': | ||
app.run(host='127.0.0.1', port=8080, debug=True, threaded=True) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from app import create_app | ||
import unittest | ||
|
||
class TestCase(unittest.TestCase): | ||
def setUp(self): | ||
self.app = create_app('Testing') | ||
self.app_context = self.app.app_context() | ||
self.app_context.push() | ||
self.client = self.app.test_client() | ||
|
||
def tearDown(self): | ||
self.app_context.pop() | ||
|
||
def test_train_nlu(self): | ||
rv = self.client.post('/nlu/build_models', json={}, follow_redirects=True) | ||
assert rv.status_code == 200 | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file was deleted.
Oops, something went wrong.