]> git.openstreetmap.org Git - nominatim.git/commitdiff
add wsgi entry point for starlette
authorSarah Hoffmann <lonvia@denofr.de>
Tue, 28 Mar 2023 13:03:00 +0000 (15:03 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Tue, 28 Mar 2023 13:03:00 +0000 (15:03 +0200)
uvicorn needs a parameter-free function to start.

nominatim/server/starlette/server.py

index be7d95d19462bbf2ac108fcc11af8d95edbae2d7..a2a70ebf0cb4a62c547ed618d6bae4c271b6dc0c 100644 (file)
@@ -60,7 +60,8 @@ def _wrap_endpoint(func: api_impl.EndpointFunc)\
 
 
 def get_application(project_dir: Path,
-                    environ: Optional[Mapping[str, str]] = None) -> Starlette:
+                    environ: Optional[Mapping[str, str]] = None,
+                    debug: bool = True) -> Starlette:
     """ Create a Nominatim falcon ASGI application.
     """
     config = Configuration(project_dir, environ)
@@ -77,8 +78,14 @@ def get_application(project_dir: Path,
     if config.get_bool('CORS_NOACCESSCONTROL'):
         middleware.append(Middleware(CORSMiddleware, allow_origins=['*']))
 
-    app = Starlette(debug=True, routes=routes, middleware=middleware)
+    app = Starlette(debug=debug, routes=routes, middleware=middleware)
 
     app.state.API = NominatimAPIAsync(project_dir, environ)
 
     return app
+
+
+def run_wsgi() -> Starlette:
+    """ Entry point for uvicorn.
+    """
+    return get_application(Path('.'), debug=False)