From 0b64919b353c86a20d7934a15d063a49d1d557ae Mon Sep 17 00:00:00 2001 From: ajnisbet Date: Mon, 19 Feb 2024 15:04:54 -0800 Subject: [PATCH] Remove now-unneeded OPTIONs methods Fixes https://github.com/ajnisbet/opentopodata/issues/93 --- opentopodata/api.py | 10 +++++----- tests/test_api.py | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/opentopodata/api.py b/opentopodata/api.py index 7f85f8c..2e0df6a 100644 --- a/opentopodata/api.py +++ b/opentopodata/api.py @@ -458,8 +458,8 @@ def _get_datasets(name): return datasets -@app.route("/", methods=["GET", "POST", "OPTIONS", "HEAD"]) -@app.route("/v1/", methods=["GET", "POST", "OPTIONS", "HEAD"]) +@app.route("/", methods=["GET", "POST", "HEAD"]) +@app.route("/v1/", methods=["GET", "POST", "HEAD"]) def get_help_message(): msg = "No dataset name provided." msg += " Try a url like '/v1/test-dataset?locations=-10,120' to get started," @@ -467,7 +467,7 @@ def get_help_message(): return jsonify({"status": "INVALID_REQUEST", "error": msg}), 404 -@app.route("/health", methods=["GET", "OPTIONS", "HEAD"]) +@app.route("/health", methods=["GET", "HEAD"]) def get_health_status(): """Status endpoint for e.g., uptime check or load balancing.""" try: @@ -480,7 +480,7 @@ def get_health_status(): return jsonify(data), 500 -@app.route("/datasets", methods=["GET", "OPTIONS", "HEAD"]) +@app.route("/datasets", methods=["GET", "HEAD"]) def get_datasets_info(): """List of datasets on the server.""" try: @@ -501,7 +501,7 @@ def get_datasets_info(): return jsonify(data), 500 -@app.route("/v1/", methods=["GET", "POST", "OPTIONS", "HEAD"]) +@app.route("/v1/", methods=["GET", "POST", "HEAD"]) def get_elevation(dataset_name): """Calculate the elevation for the given locations. diff --git a/tests/test_api.py b/tests/test_api.py index 9a2d90f..ca7f2e3 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1,7 +1,6 @@ import math import pytest -from flask_caching import Cache import rasterio from unittest.mock import patch import numpy as np @@ -9,7 +8,6 @@ from opentopodata import api from opentopodata import backend -from opentopodata import config GEOTIFF_PATH = "tests/data/datasets/test-etopo1-resampled-1deg/ETOPO1_Ice_g_geotiff.resampled-1deg.tif"