Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROG2900
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Sara Savanovic Djordjevic
PROG2900
Commits
39117aca
Commit
39117aca
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
add: error handling for /get_lake_names
parent
35f16986
No related branches found
No related tags found
1 merge request
!12
Clhp map
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/lib/server_requests/init_state.dart
+1
-2
1 addition, 2 deletions
app/lib/server_requests/init_state.dart
server/main.py
+14
-8
14 additions, 8 deletions
server/main.py
server/map_handler/lake_relations/all_lake_names.json
+1
-2
1 addition, 2 deletions
server/map_handler/lake_relations/all_lake_names.json
with
16 additions
and
12 deletions
app/lib/server_requests/init_state.dart
+
1
−
2
View file @
39117aca
...
...
@@ -27,7 +27,6 @@ Future<void> initialiseState() async {
List
<
Measurement
>
measurements
=
fetchResult
.
measurements
;
selectedMarkerList
=
measurements
;
lakeSearchOptions
=
[
"Mjøsa"
];
}
else
{
// Try to fetch measurement data from server
markerListFuture
=
fetchMeasurements
()
.
then
((
fetchResult
)
{
List
<
Measurement
>
measurements
=
fetchResult
.
measurements
;
...
...
@@ -84,6 +83,6 @@ Future<void> initSearchOptions() async {
}
}
}
catch
(
e
)
{
lakeSearchOptions
=
[
"Mjøsa"
];
// Init default list
print
(
"Failed to fetch lake names:
$e
"
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
server/main.py
+
14
−
8
View file @
39117aca
...
...
@@ -43,17 +43,23 @@ class IceHTTP(BaseHTTPRequestHandler):
self
.
wfile
.
write
(
b
"
Root path hit!
"
)
elif
self
.
path
==
'
/get_lake_names
'
:
with
open
(
LAKE_RELATIONS_PATH
+
'
all_lake_names.json
'
,
'
r
'
)
as
file
:
lake_names
=
json
.
load
(
file
)
try
:
with
open
(
LAKE_RELATIONS_PATH
+
'
all_lake_names.json
'
,
'
r
'
)
as
file
:
lake_names
=
json
.
load
(
file
)
# Disable ensure_ascii to keep 'ø'
json_data
=
json
.
dumps
(
lake_names
,
ensure_ascii
=
False
)
# Disable ensure_ascii to keep 'ø'
json_data
=
json
.
dumps
(
lake_names
,
ensure_ascii
=
False
)
self
.
send_response
(
200
)
self
.
send_header
(
'
Content-type
'
,
'
application/json
'
)
self
.
end_headers
()
self
.
send_response
(
200
)
self
.
send_header
(
'
Content-type
'
,
'
application/json
'
)
self
.
end_headers
()
self
.
wfile
.
write
(
json_data
.
encode
(
'
iso-8859-1
'
))
# Special character encoding
self
.
wfile
.
write
(
json_data
.
encode
(
'
iso-8859-1
'
))
# Special character encoding
except
Exception
as
e
:
print
(
f
"
Failed to fetch lake list:
{
e
}
"
)
self
.
send_response
(
500
)
self
.
send_header
(
'
Content-type
'
,
'
application/json
'
)
self
.
end_headers
()
elif
self
.
path
.
startswith
(
'
/update_map
'
):
# NB: should be POST?
parsed_path
=
urlparse
(
self
.
path
)
query_params
=
parse_qs
(
parsed_path
.
query
)
...
...
This diff is collapsed.
Click to expand it.
server/map_handler/lake_relations/all_lake_names.json
+
1
−
2
View file @
39117aca
...
...
@@ -7,6 +7,5 @@
"Fjellsj
\u
00c3
\u
00b8en"
,
"Gjende"
,
"Gjersj
\u
00c3
\u
00b8en"
,
"skumsj
\u
00f8en"
,
"skumsj
\u
00f8en"
"Skumsj
\u
00c3
\u
00b8en"
]
\ No newline at end of file
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