diff --git a/geomagio/WebService.py b/geomagio/WebService.py index 9926c453cb0cd81bd30a3708b7a4a0d7eb798208..b7a0ef043fa2b0a38bdf5b9f571a8201e42c5668 100644 --- a/geomagio/WebService.py +++ b/geomagio/WebService.py @@ -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) diff --git a/geomagio/WebServiceUsage.py b/geomagio/WebServiceUsage.py index 9cc4d628ff58226d7b83249e06e70ca697fc36f8..d297caa9840106dae5598e2a4142b961c5cc973f 100644 --- a/geomagio/WebServiceUsage.py +++ b/geomagio/WebServiceUsage.py @@ -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>