From c8d6cc124d6e611b09e63124920a2b915d8dac43 Mon Sep 17 00:00:00 2001 From: Christopher Hase Date: Thu, 10 Apr 2025 08:57:08 +0200 Subject: [PATCH] add http-server part 6 --- Dockerfile | 2 ++ event.ts | 9 +++++---- server.ts | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 52744d2..5a1fa93 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,4 +28,6 @@ COPY --from=rust-build /usr/local/cargo/bin/iching /usr/local/bin/iching RUN mkdir -p dist/iching RUN cp dist/*.js dist/iching/ +RUN node server.js + CMD ["npx", "http-server", "dist", "-p", "8080", "--mime", "application/javascript=js"] \ No newline at end of file diff --git a/event.ts b/event.ts index b933ed3..e776c78 100644 --- a/event.ts +++ b/event.ts @@ -3,12 +3,13 @@ function handleClick(): void { console.log("Der Button wurde geklickt!"); alert("Hallo von TypeScript!"); - /*fetch("/api/command", { method: "POST" }) + fetch("/api/command", { method: "POST" }) .then(res => res.text()) - .then(text => console.log("Server sagt:", text));*/ - fetch("https://192-168-197-2.c-one-infra.de/api/command", { method: "POST" }) + .then(text => console.log("Server sagt:", text)); + + /*fetch("https://192-168-197-2.c-one-infra.de/api/command", { method: "POST" }) .then(res => res.text()) - .then(text => console.log("Server sagt:", text)); + .then(text => console.log("Server sagt:", text)); */ } document.addEventListener("DOMContentLoaded", () => { diff --git a/server.ts b/server.ts index 9d47992..2f5e7c6 100644 --- a/server.ts +++ b/server.ts @@ -12,4 +12,4 @@ app.post('/api/command', (req, res) => { app.listen(port, '0.0.0.0', () => { console.log(`Server läuft auf http://0.0.0.0:${port}`); - }); \ No newline at end of file +}); \ No newline at end of file