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
e2593c90
Commit
e2593c90
authored
10 months ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
add: comments and docstrings to get_lake_relation.py
parent
700b2e63
No related branches found
Branches containing commit
No related tags found
1 merge request
!14
Clhp map
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/map_handler/get_lake_relation.py
+11
-2
11 additions, 2 deletions
server/map_handler/get_lake_relation.py
with
11 additions
and
2 deletions
server/map_handler/get_lake_relation.py
+
11
−
2
View file @
e2593c90
...
...
@@ -2,7 +2,15 @@ from server.consts import LAKE_RELATIONS_PATH
# Writes contents of a lake json file to the response
def
get_map_data
(
self
,
file_name
,
measurement
:
bool
):
def
get_map_data
(
self
,
file_name
:
str
,
measurement
:
bool
):
"""
Reads a map file and writes its contents to the response object.
Parameters:
self (BaseHTTPRequestHandler): A instance of a BaseHTTPRequestHandler
file_name (str): The name of the requested file/lake
measurement (bool): Whether the file is of type _measurements.json or _div.json
"""
try
:
if
measurement
:
file_type
=
"
_measurements.json
"
...
...
@@ -13,6 +21,7 @@ def get_map_data(self, file_name, measurement: bool):
with
open
(
LAKE_RELATIONS_PATH
+
file_name
+
file_type
,
"
r
"
)
as
file
:
data
=
file
.
read
()
# Set HTTP headers
self
.
send_response
(
200
)
self
.
send_header
(
"
Content-type
"
,
"
application/json
"
)
self
.
end_headers
()
...
...
@@ -23,7 +32,7 @@ def get_map_data(self, file_name, measurement: bool):
self
.
send_response
(
404
)
self
.
send_header
(
"
Content-type
"
,
"
application/json
"
)
self
.
end_headers
()
except
Exception
as
e
:
except
Exception
:
self
.
send_response
(
500
)
self
.
send_header
(
"
Content-type
"
,
"
application/json
"
)
self
.
end_headers
()
...
...
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