api = NominatimAPIAsync(project_dir, environ)
app = App(cors_enable=api.config.get_bool('CORS_NOACCESSCONTROL'))
+
+ legacy_urls = api.config.get_bool('SERVE_LEGACY_URLS')
for name, func in api_impl.ROUTES:
- app.add_route('/' + name, EndpointWrapper(func, api))
+ endpoint = EndpointWrapper(func, api)
+ app.add_route(f"/{name}", endpoint)
+ if legacy_urls:
+ app.add_route(f"/{name}.php", endpoint)
return app
from sanic_cors import CORS # pylint: disable=import-outside-toplevel
CORS(app)
+ legacy_urls = app.ctx.api.config.get_bool('SERVE_LEGACY_URLS')
for name, func in api_impl.ROUTES:
- app.add_route(_wrap_endpoint(func), f"/{name}", name=f"v1_{name}_simple")
+ endpoint = _wrap_endpoint(func)
+ app.add_route(endpoint, f"/{name}", name=f"v1_{name}_simple")
+ if legacy_urls:
+ app.add_route(endpoint, f"/{name}.php", name=f"v1_{name}_legacy")
return app
config = Configuration(project_dir, environ)
routes = []
+ legacy_urls = config.get_bool('SERVE_LEGACY_URLS')
for name, func in api_impl.ROUTES:
- routes.append(Route(f"/{name}", endpoint=_wrap_endpoint(func)))
+ endpoint = _wrap_endpoint(func)
+ routes.append(Route(f"/{name}", endpoint=endpoint))
+ if legacy_urls:
+ routes.append(Route(f"/{name}.php", endpoint=endpoint))
middleware = []
if config.get_bool('CORS_NOACCESSCONTROL'):
# Set to zero to disable polygon output.
NOMINATIM_POLYGON_OUTPUT_MAX_TYPES=1
+# Offer backwards compatible PHP URLs.
+# When running one of the Python enignes, they will add endpoint aliases
+# under <endpoint>.php
+NOMINATIM_SERVE_LEGACY_URLS=yes
+
### Log settings
#
# The following options allow to enable logging of API requests.