]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/server/sanic/server.py
add streaming json writer for JSON output
[nominatim.git] / nominatim / server / sanic / server.py
index 57b374d0742de0041253b0c2e947b31cdf5e6a42..81d62faf2853027a0415c93b98ffe66c608316a9 100644 (file)
@@ -58,7 +58,15 @@ def get_application(project_dir: Path,
 
     app.ctx.api = NominatimAPIAsync(project_dir, environ)
 
 
     app.ctx.api = NominatimAPIAsync(project_dir, environ)
 
+    if app.ctx.api.config.get_bool('CORS_NOACCESSCONTROL'):
+        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:
     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
 
     return app