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

Commit 051dd2b

Browse files
committed
Allow usage of service fabric like others flask components
1 parent b5aab1c commit 051dd2b

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
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):

0 commit comments

Comments
 (0)