Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Space Station Chatbot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dominic Daniel Krämer
Space Station Chatbot
Commits
df652c5c
Commit
df652c5c
authored
11 months ago
by
Dominic Krämer
Browse files
Options
Downloads
Patches
Plain Diff
add exceptions for failed connection
parent
47748008
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/app.py
+7
-2
7 additions, 2 deletions
app/app.py
app/static/javascript/frontend.js
+11
-0
11 additions, 0 deletions
app/static/javascript/frontend.js
with
18 additions
and
2 deletions
app/app.py
+
7
−
2
View file @
df652c5c
...
...
@@ -14,9 +14,14 @@ def home():
def
sendmessage
():
message
=
request
.
form
[
'
message
'
]
print
(
message
)
rasa_response
=
requests
.
post
(
'
http://localhost:5005/webhooks/rest/webhook
'
,
json
=
{
"
message
"
:
message
})
responses
=
[]
try
:
rasa_response
=
requests
.
post
(
'
http://localhost:5005/webhooks/rest/webhook
'
,
json
=
{
"
message
"
:
message
})
except
Exception
as
e
:
print
(
f
"
error:
{
e
}
"
)
responses
.
append
({
"
type
"
:
"
text
"
,
"
content
"
:
"
Oh, it appears that I
'
m not availabe. Please try again later!
"
})
return
jsonify
(
responses
)
for
resp
in
rasa_response
.
json
():
if
"
text
"
in
resp
:
responses
.
append
({
"
type
"
:
"
text
"
,
"
content
"
:
resp
[
"
text
"
]})
...
...
This diff is collapsed.
Click to expand it.
app/static/javascript/frontend.js
+
11
−
0
View file @
df652c5c
...
...
@@ -34,6 +34,17 @@ function sendMessage() {
chat
.
insertBefore
(
newDiv
,
chat
.
firstChild
);
// document.getElementById("chat").appendChild(newDiv);
})
.
catch
((
error
)
=>
{
console
.
error
(
error
);
let
newDiv
=
document
.
createElement
(
"
div
"
);
newDiv
.
className
=
"
message-bot
"
;
let
newP
=
document
.
createElement
(
"
p
"
);
newP
.
textContent
=
"
Oh, it appears that I'm not availabe. Please check your internet connection!
"
;
newDiv
.
appendChild
(
newP
);
let
chat
=
document
.
getElementById
(
"
chat
"
);
chat
.
insertBefore
(
newDiv
,
chat
.
firstChild
);
});
}
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment