Skip to content
This repository was archived by the owner on Jun 26, 2025. It is now read-only.

Commit 6dbff70

Browse files
authored
Merge pull request #132 from Guilhem23/master
Allow usage of service fabric like others flask components
2 parents b5aab1c + 3bab075 commit 6dbff70

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

flask_assistant/core.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,10 @@ def __init__(
100100

101101
self.api = ApiAi(dev_token, client_token)
102102

103-
if route is None and app is not None:
104-
self._route = "/"
105-
106103
if app is not None:
107104
self.init_app(app)
108105
elif blueprint is not None:
109106
self.init_blueprint(blueprint)
110-
else:
111-
raise ValueError(
112-
"Assistant object must be intialized with either an app or blueprint"
113-
)
114-
115-
if self.client_id is None:
116-
self.client_id = self.app.config.get("AOG_CLIENT_ID")
117107

118108
if project_id is None:
119109
import warnings
@@ -126,14 +116,18 @@ def __init__(
126116
)
127117

128118
def init_app(self, app):
119+
self.app = app
129120

130121
if self._route is None:
131-
raise TypeError("route is a required argument when app is not None")
122+
self._route = "/"
132123

133124
app.assist = self
134125
app.add_url_rule(
135126
self._route, view_func=self._flask_assitant_view_func, methods=["POST"]
136127
)
128+
if self.client_id is None:
129+
self.client_id = self.app.config.get("AOG_CLIENT_ID")
130+
137131

138132
# Taken from Flask-ask courtesy of @voutilad
139133
def init_blueprint(self, blueprint, path="templates.yaml"):
@@ -161,6 +155,9 @@ def init_blueprint(self, blueprint, path="templates.yaml"):
161155
"", view_func=self._flask_assitant_view_func, methods=["POST"]
162156
)
163157
# blueprint.jinja_loader = ChoiceLoader([YamlLoader(blueprint, path)])
158+
if self.client_id is None:
159+
self.client_id = self.app.config.get("AOG_CLIENT_ID")
160+
164161

165162
@property
166163
def request(self):

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ flask==1.0.2
77
google-auth==1.6.3
88
idna==2.8
99
itsdangerous==1.1.0
10-
jinja2==2.10
10+
jinja2==2.10.1
1111
markupsafe==1.1.0
1212
pyasn1-modules==0.2.7
1313
pyasn1==0.4.7
1414
requests==2.21.0
1515
rsa==4.0
1616
ruamel.yaml==0.15.81
1717
six==1.12.0
18-
urllib3==1.24.2
18+
urllib3==1.24.3
1919
werkzeug==0.15.3

0 commit comments

Comments
 (0)