diff --git a/qim3d/gui/annotation_tool.py b/qim3d/gui/annotation_tool.py
index c4b121eed6bb6edbfbabb76e98b1d67ec2e056b4..cdd29f5599bcfff96acb5bd506a9212107b03b40 100644
--- a/qim3d/gui/annotation_tool.py
+++ b/qim3d/gui/annotation_tool.py
@@ -354,10 +354,6 @@ class Operations:
 
 
 if __name__ == "__main__":
-    # Get port using the QIM API
-    port_dict = internal_tools.get_port_dict()
-    internal_tools.gradio_header(Interface().title, port_dict["port"])
-
     # Creates interface
-    app = Interface().create_interface()
-    app.launch(server_name="0.0.0.0", server_port=int(port_dict["port"]))
+    gradio_interface = Interface().create_interface()
+    internal_tools.run_gradio_app(gradio_interface)
diff --git a/qim3d/gui/data_explorer.py b/qim3d/gui/data_explorer.py
index 76ad85ef73df0e0d2dd94ca63ca9ce2b154f9285..1d6ada8744031e230c18c4b034dc079752ecc630 100644
--- a/qim3d/gui/data_explorer.py
+++ b/qim3d/gui/data_explorer.py
@@ -476,10 +476,6 @@ class Pipeline:
 
 
 if __name__ == "__main__":
-    # Get port using the QIM API
-    port_dict = internal_tools.get_port_dict()
-    internal_tools.gradio_header(Interface().title, port_dict["port"])
-
     # Creates interface
-    app = Interface().create_interface()
-    app.launch(server_name="0.0.0.0", server_port=int(port_dict["port"]))
+    gradio_interface = Interface().create_interface()
+    internal_tools.run_gradio_app(gradio_interface)
diff --git a/qim3d/gui/iso3d.py b/qim3d/gui/iso3d.py
index 60526920149c7f668ddffa5125a87c6669bd74ce..a60b761ed53e915ed18a7d8f71b67fc9abe6ebb9 100644
--- a/qim3d/gui/iso3d.py
+++ b/qim3d/gui/iso3d.py
@@ -398,10 +398,6 @@ class Interface:
 
 
 if __name__ == "__main__":
-    # Get port using the QIM API
-    port_dict = internal_tools.get_port_dict()
-    internal_tools.gradio_header(Interface().title, port_dict["port"])
-
     # Creates interface
-    app = Interface().create_interface()
-    app.launch(server_name="0.0.0.0", server_port=int(port_dict["port"]))
+    gradio_interface = Interface().create_interface()
+    internal_tools.run_gradio_app(gradio_interface)
diff --git a/qim3d/gui/local_thickness.py b/qim3d/gui/local_thickness.py
index fa4dda339235b33dab8de9518a2f98a5fc2ddddb..1e179eed1effbc60d071237e75e279dab3027965 100644
--- a/qim3d/gui/local_thickness.py
+++ b/qim3d/gui/local_thickness.py
@@ -12,7 +12,6 @@ import plotly.graph_objects as go
 import localthickness as lt
 import matplotlib
 
-
 # matplotlib.use("Agg")
 import matplotlib.pyplot as plt
 
@@ -424,10 +423,6 @@ class Pipeline:
 
 
 if __name__ == "__main__":
-    # Get port using the QIM API
-    port_dict = internal_tools.get_port_dict()
-    internal_tools.gradio_header(Interface().title, port_dict["port"])
-
     # Creates interface
-    app = Interface().create_interface()
-    app.launch(server_name="0.0.0.0", server_port=int(port_dict["port"]))
+    gradio_interface = Interface().create_interface()
+    internal_tools.run_gradio_app(gradio_interface)
diff --git a/qim3d/utils/internal_tools.py b/qim3d/utils/internal_tools.py
index eb18c11b0f667ea4f91b341d4470050f360228b7..b168ac9470f91485277d322d72781832ac1f9a78 100644
--- a/qim3d/utils/internal_tools.py
+++ b/qim3d/utils/internal_tools.py
@@ -14,7 +14,9 @@ import getpass
 from PIL import Image
 from pathlib import Path
 from qim3d.io.logger import log
-
+from fastapi import FastAPI
+import gradio as gr
+from uvicorn import run
 
 def mock_plot():
     """Creates a mock plot of a sine wave.
@@ -265,3 +267,20 @@ def get_port_dict():
         raise (f"Error: {response.status_code}")
 
     return port_dict
+
+def run_gradio_app(gradio_interface):
+    host = "0.0.0.0"
+    # Get port using the QIM API
+    port_dict = get_port_dict()
+    gradio_header(gradio_interface.title, port_dict["port"])
+
+    # Create FastAPI with mounted gradio interface
+    app = FastAPI()
+    path = f"/gui/{port_dict['username']}/{port_dict['port']}/"
+    app = gr.mount_gradio_app(app, gradio_interface, path=path)
+
+    # Full path
+    print(f"http://{host}:{port_dict['port']}{path}")
+
+    # Run the FastAPI server usign uvicorn
+    run(app, host="0.0.0.0", port=int(port_dict["port"]))