diff --git a/kadi_apps/app.py b/kadi_apps/app.py index 763f027..727809d 100755 --- a/kadi_apps/app.py +++ b/kadi_apps/app.py @@ -30,6 +30,13 @@ def index(): ) +def api_index(): + """Return main API page""" + return render_template( + 'api_index.html', + ) + + def get_app(name=__name__, settings='devel'): import kadi_apps from kadi_apps.blueprints import auth, test, ska_api as api, kadi, find_attitude @@ -61,6 +68,7 @@ def get_app(name=__name__, settings='devel'): app.register_error_handler(500, internal_error) app.add_url_rule("/", view_func=index) + app.add_url_rule("/api", view_func=api_index) app.register_blueprint(kadi.blueprint, url_prefix='/kadi') app.register_blueprint(find_attitude.blueprint, url_prefix='/find_attitude') diff --git a/kadi_apps/blueprints/ska_api/api.py b/kadi_apps/blueprints/ska_api/api.py index 219f889..821ca5b 100644 --- a/kadi_apps/blueprints/ska_api/api.py +++ b/kadi_apps/blueprints/ska_api/api.py @@ -1,4 +1,4 @@ -from flask import Blueprint, render_template +from flask import Blueprint from flask import request import logging @@ -20,12 +20,6 @@ blueprint = Blueprint('ska_api', __name__, template_folder='templates') -@blueprint.route("/") -def show_help(): - """Return help page for web-kadi API access""" - return render_template('help.html') - - class NotFound(Exception): pass diff --git a/kadi_apps/blueprints/ska_api/templates/help.html b/kadi_apps/blueprints/ska_api/templates/help.html deleted file mode 100644 index 9c22288..0000000 --- a/kadi_apps/blueprints/ska_api/templates/help.html +++ /dev/null @@ -1,435 +0,0 @@ - - - -
- - -A subset of Ska3 Python data APIs are accessible via the -http://web-kadi.cfa.harvard.edu/api web interface. Available data sets are:
- -The general URL syntax for querying data via the API interface is as follows:
-- {{ url_for('ska_api.api', path='asdasdasd', _external=True) }}/<package>/<module>/<function>?<arg1>=<val1>&<arg2>=val2... --
This roughly equivalent to the Python pseudo-code:
--from <package>.<module> import <function> -<function>(arg1=val1, arg2=val2) --
For example:
- -This is equivalent to the Python code:
--from kadi.events import manvrs -manvrs.filter(start='2019:001', stop='2019:002') --
The web API query returns a JSON-encoded version of the manvrs data structure -(Content-type: application/json).
-One special option which is common to all queries is the table_format, which can take the value -rows or columns (default=``rows``). This specifies whether to return any tabular data as -either a list of dicts (rows) or a dict of lists (columns). For large query results the -columns option will generally be more compact because the table column names are not repeated for -every row. For example:
- -A second special option is report_timing, which returns timing information on the query -instead of the query data. This may be useful for characterizing the performance of the -web service (which is not very speedy). Example:
- -The full list of available API functions are:
--/api/kadi/events/<event_type>/filter -/api/kadi/commands/states/get_states -/api/kadi/commands/get_cmds -/api/mica/starcheck/get_att -/api/mica/starcheck/get_dither -/api/mica/starcheck/get_monitor_windows -/api/mica/starcheck/get_mp_dir -/api/mica/starcheck/get_starcat -/api/mica/starcheck/get_starcheck_catalog -/api/mica/starcheck/get_starcheck_catalog_at_date --
+ The Ska API is a generic API that wraps a subset of the Ska3 Python API. It is accessible via + the {{ url_for('ska_api.api', path="", _external=True) }} + web interface. The available data sets are: +
+ ++ The general URL syntax for querying data via the API interface is as follows: +
++ {{ url_for('ska_api.api', path="", _external=True) }}<package>/<module>/<function>?<arg1>=<val1>&<arg2>=val2... ++
+ This roughly equivalent to the Python pseudo-code: +
++ from <package>.<module> import <function> + <function>(arg1=val1, arg2=val2) ++ +
For example:
+ +is equivalent to the Python code:
++ from kadi.events import manvrs + manvrs.filter(start='2019:001', stop='2019:002') ++ +
The web API query returns a JSON-encoded version of the manvrs data structure +(Content-type: application/json).
+One special option which is common to all queries is the table_format, which can take the value +rows or columns (default=``rows``). This specifies whether to return any tabular data as +either a list of dicts (rows) or a dict of lists (columns). For large query results the +columns option will generally be more compact because the table column names are not repeated for +every row. For example:
+ + +The full list of available entrypoints:
++ {{ url_for('ska_api.api', path="") }}agasc/get_star + {{ url_for('ska_api.api', path="") }}agasc/get_stars + {{ url_for('ska_api.api', path="") }}agasc/get_star_cone + {{ url_for('ska_api.api', path="") }}kadi/events/<event_type>/filter + {{ url_for('ska_api.api', path="") }}kadi/commands/states/get_states + {{ url_for('ska_api.api', path="") }}kadi/commands/get_cmds + {{ url_for('ska_api.api', path="") }}kadi/commands/get_observations + {{ url_for('ska_api.api', path="") }}kadi/commands/get_starcats + {{ url_for('ska_api.api', path="") }}mica/archive/aca_dark/dark_cal/get_dark_cal_id + {{ url_for('ska_api.api', path="") }}mica/archive/aca_dark/dark_cal/get_dark_cal_ids + {{ url_for('ska_api.api', path="") }}mica/archive/aca_dark/dark_cal/get_dark_cal_image + {{ url_for('ska_api.api', path="") }}mica/archive/aca_dark/dark_cal/get_dark_cal_props + {{ url_for('ska_api.api', path="") }}mica/starcheck/get_att + {{ url_for('ska_api.api', path="") }}mica/starcheck/get_dither + {{ url_for('ska_api.api', path="") }}mica/starcheck/get_monitor_windows + {{ url_for('ska_api.api', path="") }}mica/starcheck/get_mp_dir + {{ url_for('ska_api.api', path="") }}mica/starcheck/get_starcat + {{ url_for('ska_api.api', path="") }}mica/starcheck/get_starcheck_catalog + {{ url_for('ska_api.api', path="") }}mica/starcheck/get_starcheck_catalog_at_date ++ +{% endblock %} diff --git a/kadi_apps/templates/base.html b/kadi_apps/templates/base.html index 651f767..19f6454 100644 --- a/kadi_apps/templates/base.html +++ b/kadi_apps/templates/base.html @@ -42,17 +42,18 @@ -