Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
geomag-algorithms
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
ghsc
National Geomagnetism Program
geomag-algorithms
Commits
6649b8aa
Commit
6649b8aa
authored
7 years ago
by
Hunsinger, Heather Elizabeth
Browse files
Options
Downloads
Patches
Plain Diff
Show documentation page for empty query string
parent
cb59f2bd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
geomagio/WebService.py
+5
-6
5 additions, 6 deletions
geomagio/WebService.py
geomagio/WebServiceUsage.py
+19
-7
19 additions, 7 deletions
geomagio/WebServiceUsage.py
with
24 additions
and
13 deletions
geomagio/WebService.py
+
5
−
6
View file @
6649b8aa
...
...
@@ -80,6 +80,9 @@ class WebService(object):
def
__call__
(
self
,
environ
,
start_response
):
"""
Implement WSGI interface
"""
if
environ
[
'
QUERY_STRING
'
]
==
''
:
usage_page
=
WebServiceUsage
().
set_usage_page
(
start_response
)
return
[
usage_page
]
try
:
# parse params
query
=
self
.
parse
(
parse_qs
(
environ
[
'
QUERY_STRING
'
]))
...
...
@@ -87,12 +90,8 @@ class WebService(object):
except
Exception
:
exception
=
sys
.
exc_info
()[
1
]
message
=
exception
.
args
[
0
]
if
message
==
'"
id
"
is a required parameter.
'
:
usage_page
=
WebServiceUsage
().
set_usage_page
(
start_response
)
return
[
usage_page
]
else
:
error_body
=
self
.
error
(
400
,
message
,
environ
,
start_response
)
return
[
error_body
]
error_body
=
self
.
error
(
400
,
message
,
environ
,
start_response
)
return
[
error_body
]
try
:
# fetch timeseries
timeseries
=
self
.
fetch
(
query
)
...
...
This diff is collapsed.
Click to expand it.
geomagio/WebServiceUsage.py
+
19
−
7
View file @
6649b8aa
...
...
@@ -2,6 +2,7 @@
from
datetime
import
datetime
from
geomagio.ObservatoryMetadata
import
ObservatoryMetadata
class
WebServiceUsage
(
object
):
def
__init__
(
self
,
metadata
=
None
):
metadata
=
metadata
or
ObservatoryMetadata
().
metadata
.
keys
()
...
...
@@ -18,7 +19,8 @@ class WebServiceUsage(object):
<head>
<title>Geomag Web Service Usage</title>
<meta charset=
"
utf-8
"
/>
<meta name=
"
viewport
"
content=
"
width=device-width, initial-scale=1
"
/>
<meta name=
"
viewport
"
content=
"
width=device-width,
initial-scale=1
"
/>
<link href=
"
/theme/site/geomag/index.scss
"
type=
"
text/css
"
>
<style>
code,
...
...
@@ -40,9 +42,11 @@ class WebServiceUsage(object):
<h2>Example Requests</h3>
<dl>
<b>BOU observatory data for current UTC day in IAGA2002 format</b>
<b>BOU observatory data for current UTC day in IAGA2002
format</b>
<dd>
<a href=
"
http://geomag.usgs.gov/ws/edge/?id=BOU
"
>http://geomag.usgs.gov/ws/edge/?id=BOU</a>
<a href=
"
http://geomag.usgs.gov/ws/edge/?id=BOU
"
>
http://geomag.usgs.gov/ws/edge/?id=BOU</a>
</dd>
...
...
@@ -59,7 +63,8 @@ class WebServiceUsage(object):
<dd>
Time of first requested data.<br/>
Default: start of current UTC day<br/>
Format: ISO8601 (<code>YYYY-MM-DDTHH:MM:SSZ</code>)<br/>
Format: ISO8601
(<code>YYYY-MM-DDTHH:MM:SSZ</code>)<br/>
Example: <code>{date}</code>
</dd>
...
...
@@ -67,7 +72,8 @@ class WebServiceUsage(object):
<dd>
Time of last requested data.<br/>
Default: starttime + 24 hours<br/>
Format: ISO8601 (<code>YYYY-MM-DDTHH:MM:SSZ</code>)<br/>
Format: ISO8601
(<code>YYYY-MM-DDTHH:MM:SSZ</code>)<br/>
Example: <code>{date}</code>
</dd>
...
...
@@ -75,6 +81,9 @@ class WebServiceUsage(object):
<dd>
Comma separated list of requested elements.<br/>
Default: <code>X,Y,Z,F</code><br/>
Valid values: <code>D, DIST, DST, E, E-E, E-N, F, G,
H, SQ, SV, UK1, UK2, UK3, UK4, X, Y, Z</code>
<br/>
</dd>
<b>sampling_period</b>
<dd>
...
...
@@ -110,11 +119,14 @@ class WebServiceUsage(object):
<nav class=
"
site-footer
"
>
<p> Not what you were looking for?<br/>
Search usa.gov: </p>
<form class=
"
site-search
"
role=
"
search
"
action=
"
//search.usa.gov/search
"
method=
"
get
"
accept-charset=
"
UTF-8
"
>
<form class=
"
site-search
"
role=
"
search
"
action=
"
//search.usa.gov/search
"
method=
"
get
"
accept-charset=
"
UTF-8
"
>
<input name=
"
utf8
"
type=
"
hidden
"
value=
"
x
"
/>
<input name=
"
affiliate
"
type=
"
hidden
"
value=
"
usgs
"
/>
<input name=
"
sitelimit
"
type=
"
hidden
"
/>
<input id=
"
query
"
name=
"
query
"
type=
"
search
"
placeholder=
"
Search usa.gov...
"
title=
"
Search
"
/>
<input id=
"
query
"
name=
"
query
"
type=
"
search
"
placeholder=
"
Search usa.gov...
"
title=
"
Search
"
/>
<button type=
"
submit
"
>Search</button>
</form>
</nav>
...
...
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