]> git.ipfire.org Git - pbs.git/commitdiff
API: Move the app into __init__.py
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 15 Jun 2025 14:07:38 +0000 (14:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 15 Jun 2025 14:07:38 +0000 (14:07 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/api/__init__.py
src/api/app.py [deleted file]
src/api/builds.py

index d139bc3f772a9baa0b6224953c516bdbe7c247d3..bc99be5692b596449f2a2bca9e78376d75a61cf7 100644 (file)
@@ -122,7 +122,6 @@ CLEANFILES += \
 
 api_PYTHON = \
        src/api/__init__.py \
-       src/api/app.py \
        src/api/builds.py
 
 apidir = $(pkgpythondir)/api
index e55f07f5f463907d1541d27cc87de7dd55b7ebfe..c98c56ff9bb2ebba0c874b9db9c30a66a78b93eb 100644 (file)
 #                                                                             #
 ###############################################################################
 
+import fastapi
+import fastapi.middleware.cors
+
 from .. import Backend
 
 # Initialize the backend
 backend = Backend("/etc/pakfire/pbs.conf")
 #backend.launch_background_tasks()
 
-# Import the app
-from .app import app
+# Initialize the app
+app = fastapi.FastAPI(
+       title = "Pakfire Build Service API",
+       version = "0.0.1",
+
+       # Enable debug mode
+       debug = True,
+)
+
+# Add CORS
+app.add_middleware(
+       fastapi.middleware.cors.CORSMiddleware,
+       allow_origins=["https://pakfire.ipfire.org"],
+       allow_credentials=True,
+       allow_methods=["*"],
+       allow_headers=["*"],
+)
+
+# Load all further modules
+from . import builds
diff --git a/src/api/app.py b/src/api/app.py
deleted file mode 100644 (file)
index bd87beb..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-###############################################################################
-#                                                                             #
-# Pakfire - The IPFire package management system                              #
-# Copyright (C) 2025 Pakfire development team                                 #
-#                                                                             #
-# This program is free software: you can redistribute it and/or modify        #
-# it under the terms of the GNU General Public License as published by        #
-# the Free Software Foundation, either version 3 of the License, or           #
-# (at your option) any later version.                                         #
-#                                                                             #
-# This program is distributed in the hope that it will be useful,             #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
-# GNU General Public License for more details.                                #
-#                                                                             #
-# You should have received a copy of the GNU General Public License           #
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
-#                                                                             #
-###############################################################################
-
-import fastapi
-import fastapi.middleware.cors
-
-app = fastapi.FastAPI(
-       title = "Pakfire Build Service API",
-       version = "0.0.1",
-
-       # Enable debug mode
-       debug = True,
-)
-
-# Add CORS
-app.add_middleware(
-       fastapi.middleware.cors.CORSMiddleware,
-       allow_origins=["https://pakfire.ipfire.org"],
-       allow_credentials=True,
-       allow_methods=["*"],
-       allow_headers=["*"],
-)
-
-# Load all further modules
-from . import builds
index f93fab7b987042fa2ab139b802989273e6a89170..a22b57aeaddd9852ca05aa27c3a6aa188c8a20b1 100644 (file)
@@ -21,7 +21,7 @@
 import fastapi
 import uuid
 
-from .app import app
+from . import app
 from . import backend
 
 @app.get("/builds/{build_id}")