Skip to content

Commit

Permalink
Added dynamic IP resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
wene37 committed May 10, 2023
1 parent 072282d commit a8f1bae
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import json
import os
import subprocess

from flask import Flask, render_template, request

from Helper import Helper

configParser = Helper.loadConfig()
ip = subprocess.call("hostname -I")
port = configParser.getint("WebApp", "Port")
publicKey = configParser.get("WebApp", "WebPushPublicKey")

Expand Down Expand Up @@ -40,7 +43,7 @@ def pushNotification():

@app.route('/')
def index():
return render_template('index.html', PublicKey=publicKey, Port=port, LogOutput=getLogs())
return render_template('index.html', PublicKey=publicKey, IP=ip, Port=port, LogOutput=getLogs())

if __name__ == '__main__':
app.run(debug=True, port=port, host='0.0.0.0')
2 changes: 1 addition & 1 deletion src/static/serviceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ self.addEventListener("notificationclick", function (e) {
notification.close();
} else {
// Some actions
clients.openWindow("http://127.0.0.1:" + port);
clients.openWindow("http://" + ip + ":" + port);
notification.close();
}
});
1 change: 1 addition & 0 deletions src/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<meta name="msapplication-TileImage" content="{{url_for('static', filename='images/favicon/icon-114.png')}}">
<meta name="theme-color" content="#121212">
<script type="text/javascript">
var ip = "{{IP}}"
var port = "{{Port}}"
</script>
</head>
Expand Down

0 comments on commit a8f1bae

Please sign in to comment.