From 1e04e6a2959d7174421be40333e3e3d7fbfcd683 Mon Sep 17 00:00:00 2001 From: Christopher Hase Date: Wed, 9 Apr 2025 16:51:26 +0200 Subject: [PATCH] add http-server part 5.11 --- event.ts | 9 ++++++--- server.ts | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/event.ts b/event.ts index 19cc125..e157d02 100644 --- a/event.ts +++ b/event.ts @@ -1,13 +1,16 @@ -import { executeCommand } from './broker.js'; +//import { executeCommand } from './broker.js'; function handleClick(): void { console.log("Der Button wurde geklickt!"); alert("Hallo von TypeScript!"); //executeCommand(); - fetch("/api/command", { method: "POST" }) + /*fetch("/api/command", { method: "POST" }) .then(res => res.text()) - .then(text => console.log("Server sagt:", text)); + .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)); } document.addEventListener("DOMContentLoaded", () => { diff --git a/server.ts b/server.ts index 231c960..4aa21b5 100644 --- a/server.ts +++ b/server.ts @@ -3,13 +3,13 @@ import express from 'express'; import { executeCommand } from './broker'; const app = express(); -const port = 8080; +const port = 8090; app.post('/api/command', (req, res) => { executeCommand(); res.status(200).send('Command executed'); }); -app.listen(port, () => { - console.log(`Server läuft auf http://localhost:${port}`); -}); \ No newline at end of file +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