From 04e7fc934b8585deeefe8d02370939f68510b7b8 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Fri, 2 Jun 2023 10:18:16 +0100
Subject: [PATCH] Separate package with the uwsgi entry point

---
 Dockerfile             |  2 +-
 mat_api_server/api.py  |  8 --------
 mat_api_server/wsgi.py | 11 +++++++++++
 3 files changed, 12 insertions(+), 9 deletions(-)
 create mode 100644 mat_api_server/wsgi.py

diff --git a/Dockerfile b/Dockerfile
index 5c6d03e..aa93996 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -27,4 +27,4 @@ RUN cd /tmp/wheels \
 
 ENV VIRTUALENV=/virtualenv
 ENV UWSGI_ENGINE=threads
-ENV WSGI_APP=mat_api_server.api:create_app
+ENV WSGI_APP=mat_api_server.wsgi:application
diff --git a/mat_api_server/api.py b/mat_api_server/api.py
index 67d1a76..aef454d 100644
--- a/mat_api_server/api.py
+++ b/mat_api_server/api.py
@@ -9,14 +9,6 @@ import tempfile
 app = Flask(__name__)
 
 
-def create_app():
-    # Simple config from environment variables.
-    app.config.update({
-        'UPLOAD_DIR': os.getenv('UPLOAD_DIR'),
-    })
-    return app
-
-
 def get_parser_by_mime_type(path, mime_type):
     for parser_class in parser_factory._get_parsers():
         if mime_type in parser_class.mimetypes:
diff --git a/mat_api_server/wsgi.py b/mat_api_server/wsgi.py
new file mode 100644
index 0000000..413dcd5
--- /dev/null
+++ b/mat_api_server/wsgi.py
@@ -0,0 +1,11 @@
+import os
+from .api import app
+
+
+# Simple config from environment variables.
+app.config.update({
+    'UPLOAD_DIR': os.getenv('UPLOAD_DIR'),
+})
+
+
+application = app
-- 
GitLab