diff --git a/backend/pilotwings.py b/backend/pilotwings.py
index a618cf4..e82926f 100644
--- a/backend/pilotwings.py
+++ b/backend/pilotwings.py
@@ -1,7 +1,7 @@
from os import getenv, path
-from typing import Annotated
+from typing import Annotated, Any
-from docker import from_env
+from docker import errors, from_env
from dotenv import load_dotenv
from fastapi import Depends, FastAPI, HTTPException, Request
from fastapi.security import HTTPBasic, HTTPBasicCredentials
@@ -72,6 +72,25 @@ def get_containers(
]
+@app.get("/api/container/{container_name}")
+def get_container(
+ container_name: str,
+ credentials: Annotated[HTTPBasicCredentials, Depends(security)],
+) -> dict[str, Any]:
+ try:
+ container = client.containers.get(container_name)
+ except errors.APIError:
+ raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
+
+ if (
+ credentials.username != "admin"
+ and f"owner={credentials.username}" not in container.labels
+ ):
+ raise HTTPException(status_code=status.HTTP_403_FORBIDDEN)
+
+ return container.attrs
+
+
app.mount(
"/",
AuthStaticFiles(
diff --git a/frontend/main.ts b/frontend/main.ts
index 7d55fea..3d119a1 100644
--- a/frontend/main.ts
+++ b/frontend/main.ts
@@ -2,7 +2,7 @@ import 'bulma/css/bulma.min.css'
import 'font-awesome/css/font-awesome.min.css'
import App from './App.vue'
import { createApp } from 'vue'
-import router from './router'
+import router from './router.ts'
const app = createApp(App)
app.use(router)
diff --git a/frontend/router/index.ts b/frontend/router.ts
similarity index 55%
rename from frontend/router/index.ts
rename to frontend/router.ts
index 328b00f..8737e76 100644
--- a/frontend/router/index.ts
+++ b/frontend/router.ts
@@ -1,13 +1,17 @@
import { createRouter, createWebHistory } from 'vue-router'
-import Containers from '../views/Containers.vue'
+import Container from './views/Container.vue'
+import Home from './views/Home.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
- name: 'home',
- component: Containers,
+ component: Home,
+ },
+ {
+ path: '/container/:name',
+ component: Container,
},
],
})
diff --git a/frontend/views/Container.vue b/frontend/views/Container.vue
new file mode 100644
index 0000000..106f1a8
--- /dev/null
+++ b/frontend/views/Container.vue
@@ -0,0 +1,9 @@
+
+