Skip to content

Commit

Permalink
Merge pull request #132 from Guilhem23/master
Browse files Browse the repository at this point in the history
Allow usage of service fabric like others flask components
  • Loading branch information
treethought committed May 4, 2020
2 parents b5aab1c + 3bab075 commit 6dbff70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
19 changes: 8 additions & 11 deletions flask_assistant/core.py
Expand Up @@ -100,20 +100,10 @@ def __init__(

self.api = ApiAi(dev_token, client_token)

if route is None and app is not None:
self._route = "/"

if app is not None:
self.init_app(app)
elif blueprint is not None:
self.init_blueprint(blueprint)
else:
raise ValueError(
"Assistant object must be intialized with either an app or blueprint"
)

if self.client_id is None:
self.client_id = self.app.config.get("AOG_CLIENT_ID")

if project_id is None:
import warnings
Expand All @@ -126,14 +116,18 @@ def __init__(
)

def init_app(self, app):
self.app = app

if self._route is None:
raise TypeError("route is a required argument when app is not None")
self._route = "/"

app.assist = self
app.add_url_rule(
self._route, view_func=self._flask_assitant_view_func, methods=["POST"]
)
if self.client_id is None:
self.client_id = self.app.config.get("AOG_CLIENT_ID")


# Taken from Flask-ask courtesy of @voutilad
def init_blueprint(self, blueprint, path="templates.yaml"):
Expand Down Expand Up @@ -161,6 +155,9 @@ def init_blueprint(self, blueprint, path="templates.yaml"):
"", view_func=self._flask_assitant_view_func, methods=["POST"]
)
# blueprint.jinja_loader = ChoiceLoader([YamlLoader(blueprint, path)])
if self.client_id is None:
self.client_id = self.app.config.get("AOG_CLIENT_ID")


@property
def request(self):
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Expand Up @@ -7,13 +7,13 @@ flask==1.0.2
google-auth==1.6.3
idna==2.8
itsdangerous==1.1.0
jinja2==2.10
jinja2==2.10.1
markupsafe==1.1.0
pyasn1-modules==0.2.7
pyasn1==0.4.7
requests==2.21.0
rsa==4.0
ruamel.yaml==0.15.81
six==1.12.0
urllib3==1.24.2
urllib3==1.24.3
werkzeug==0.15.3

0 comments on commit 6dbff70

Please sign in to comment.