I have a basic Electron application that runs an Express server. When a client visits the server's index page, I return a "Hello World" response. However, I also keep track of the number of visitors and want to update this number in Electron's BrowserWindow (not on the client window).
The setup for the Electron app is similar to the Hello World example, except that it also calls the express-server module.
The important parts of my express-server are:
var visitor = 0
app.get('/', (req, res) => {
res.send('Hello World'); // Message sent to the client.
visitor += 1; // I want to then update the visitor number in the Electron window.
})
The Electron app loads an index page:
<html>
<head></head>
<body>
<p>The server has been hit <span id="num-visitors">0</span> times.</p>
</body>
</html>
I want to set the innerText inside "num-visitors" to be the number of visitors from the express-server module. But how will I have access to Electron's BrowserWindow from the express-server module? And how can I modify only part of the index page?
Aucun commentaire:
Enregistrer un commentaire