This commit is contained in:
parent
0189cc2157
commit
1ddfc8c769
5 changed files with 18 additions and 15 deletions
|
@ -22,7 +22,7 @@ export function executeCommand(): void {
|
||||||
|
|
||||||
exec('iching divine', (error, stdout, stderr) => {
|
exec('iching divine', (error, stdout, stderr) => {
|
||||||
|
|
||||||
console.log(`Begin`);
|
console.log(`I-Ching-Broker: \'iching divine\' called`);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error(`Error: ${error.message}`);
|
console.error(`Error: ${error.message}`);
|
||||||
|
@ -39,7 +39,7 @@ export function executeCommand(): void {
|
||||||
config = loadConfig();
|
config = loadConfig();
|
||||||
} */
|
} */
|
||||||
|
|
||||||
console.log(`Send E-Mail`);
|
console.log(`Horoscope received; sending E-Mail next`);
|
||||||
sendEmail(stdout);
|
sendEmail(stdout);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -75,9 +75,11 @@ async function sendEmail(content: string) {
|
||||||
html: html(content)
|
html: html(content)
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("E-Mail sent: ", info.messageId + "\n");
|
console.log("E-Mail sent: ", info.messageId + "\n\n");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error Sending E-Mail:", error);
|
console.error("Error Sending E-Mail:", error + "\n\n");
|
||||||
|
|
||||||
|
console.log("Failed to send horoscope: \n", content + "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +121,7 @@ function parse(input: string): Node {
|
||||||
const changingLines: Node = { type: "ChangingLines"};
|
const changingLines: Node = { type: "ChangingLines"};
|
||||||
currentNode.child = changingLines;
|
currentNode.child = changingLines;
|
||||||
currentNode = changingLines;
|
currentNode = changingLines;
|
||||||
currentNode.value = line; // + "<br>"; TODO: try without this <br>
|
currentNode.value = line;
|
||||||
} else {
|
} else {
|
||||||
currentNode.value = currentNode.value + line + "<br>";
|
currentNode.value = currentNode.value + line + "<br>";
|
||||||
}
|
}
|
||||||
|
@ -132,13 +134,11 @@ function parse(input: string): Node {
|
||||||
function render(node: Node): string {
|
function render(node: Node): string {
|
||||||
|
|
||||||
if (node == undefined) {
|
if (node == undefined) {
|
||||||
console.log("Rendering of nodes finished!")
|
console.log("I-Ching-Broker: Rendering of nodes finished!")
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Render node" + node.type);
|
|
||||||
|
|
||||||
var outputHTML: string = "";
|
var outputHTML: string = "";
|
||||||
|
|
||||||
switch (node.type) {
|
switch (node.type) {
|
||||||
|
@ -161,7 +161,6 @@ function render(node: Node): string {
|
||||||
case "ChangingLines" :
|
case "ChangingLines" :
|
||||||
const regex = new RegExp("~", "g");
|
const regex = new RegExp("~", "g");
|
||||||
node.value = node.value?.replace(regex, "");
|
node.value = node.value?.replace(regex, "");
|
||||||
//outputHTML = "<br><p><div style=\"border: 1px dashed gray; border-radius: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px; width: auto; display: inline-block; color: gray; text-align: center; box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2);\">" + node.value + "</div></p><br>";
|
|
||||||
outputHTML = "<br><br><p><div style=\"padding-left: 20px; padding-right: 20px; padding-top: 20px; display: inline-block; color: gray; text-align: center;\">" + node.value + "</div></p><br>";
|
outputHTML = "<br><br><p><div style=\"padding-left: 20px; padding-right: 20px; padding-top: 20px; display: inline-block; color: gray; text-align: center;\">" + node.value + "</div></p><br>";
|
||||||
outputHTML = outputHTML + render(node.child!);
|
outputHTML = outputHTML + render(node.child!);
|
||||||
return outputHTML;
|
return outputHTML;
|
||||||
|
|
|
@ -8,10 +8,13 @@ const port = 8090;
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
|
|
||||||
app.post('/iching/api/command', (req, res) => {
|
app.post('/iching/api/command', (req, res) => {
|
||||||
|
//TODO no logging from inside this method???
|
||||||
|
console.log(`Backend-Server: receiving POST to /iching/api/command`);
|
||||||
|
|
||||||
executeCommand();
|
executeCommand();
|
||||||
res.status(200).send('Command executed\n');
|
res.status(200).send('Backend-Server: Broker was called\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
app.listen(port, '0.0.0.0', () => {
|
app.listen(port, '0.0.0.0', () => {
|
||||||
console.log(`Server läuft auf http://0.0.0.0:${port}`);
|
console.log(`Backend-Server running on http://0.0.0.0:${port}`);
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,8 +3,8 @@ function handleClick(): void {
|
||||||
|
|
||||||
fetch("/iching/api/command", { method: "POST" })
|
fetch("/iching/api/command", { method: "POST" })
|
||||||
.then(res => res.text())
|
.then(res => res.text())
|
||||||
.then(text => console.log("Server sagt:", text))
|
.then(text => console.log("HTTP-Server says:", text))
|
||||||
.catch(error => console.error("Fehler:", error));
|
.catch(error => console.error("HTTP-Server - Error:", error));
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
|
|
@ -53,10 +53,11 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1>🧘 My I-Ging Horoscope</h1>
|
<h1>Do you want to know the future?</h1>
|
||||||
|
<h2> ☝️ Look into the future with your personal I-Ging Horoscope! ☝️</h2>
|
||||||
<p>Click on the Button to receive your personal Horoscope. 100% accuracy guaranteed!</p>
|
<p>Click on the Button to receive your personal Horoscope. 100% accuracy guaranteed!</p>
|
||||||
<button id="myButton">✨ Receive Horoscope ✨</button>
|
<button id="myButton">✨ Receive Horoscope ✨</button>
|
||||||
<div class="footer">With Love & Fortune from the Cosmos 💫</div>
|
<div class="footer">🧘 With Love & Fortune from the Cosmos 💫</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="module" src="./event.mjs"></script>
|
<script type="module" src="./event.mjs"></script>
|
||||||
|
|
0
start.sh
Normal file → Executable file
0
start.sh
Normal file → Executable file
Loading…
Reference in a new issue