import Admin module based on runtime configuration (#1469) (#1485)

This commit is contained in:
Tom Kralidis
2024-01-09 17:32:47 -05:00
committed by GitHub
parent fe7ea108a7
commit 635562f966
3 changed files with 10 additions and 6 deletions
+4 -4
View File
@@ -39,7 +39,6 @@ from typing import Tuple, Dict, Mapping, Optional
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from pygeoapi.admin import Admin
from pygeoapi.api import API
@@ -544,10 +543,11 @@ def _feed_response(request: HttpRequest, api_definition: str,
*args, **kwargs) -> Tuple[Dict, int, str]:
"""Use pygeoapi api to process the input request"""
if 'admin' not in api_definition:
api_ = API(settings.PYGEOAPI_CONFIG)
else:
if 'admin' in api_definition and settings.PYGEOAPI_CONFIG['server'].get('admin'): # noqa
from pygeoapi.admin import Admin
api_ = Admin(settings.PYGEOAPI_CONFIG)
else:
api_ = API(settings.PYGEOAPI_CONFIG)
api = getattr(api_, api_definition)
+3 -1
View File
@@ -36,7 +36,6 @@ import click
from flask import Flask, Blueprint, make_response, request, send_from_directory
from pygeoapi.admin import Admin
from pygeoapi.api import API
from pygeoapi.openapi import load_openapi_document
from pygeoapi.config import get_config
@@ -48,6 +47,9 @@ OPENAPI = load_openapi_document()
API_RULES = get_api_rules(CONFIG)
if CONFIG['server'].get('admin'):
from pygeoapi.admin import Admin
STATIC_FOLDER = 'static'
if 'templates' in CONFIG['server']:
STATIC_FOLDER = CONFIG['server']['templates'].get('static', 'static')
+3 -1
View File
@@ -50,7 +50,6 @@ from starlette.responses import (
import uvicorn
from pygeoapi.api import API
from pygeoapi.admin import Admin
from pygeoapi.openapi import load_openapi_document
from pygeoapi.config import get_config
from pygeoapi.util import get_api_rules
@@ -62,6 +61,9 @@ if 'PYGEOAPI_OPENAPI' not in os.environ:
OPENAPI = load_openapi_document()
if CONFIG['server'].get('admin'):
from pygeoapi.admin import Admin
p = Path(__file__)
APP = Starlette(debug=True)