I'm making my chat application. When i run the source code, it works. But when i try to use my EXE, (all files exist in the run directory) It launches Chromium (in --app mode with my page), but after a few seconds, the server stops. Here is my code:
import eel
import eel.browsers
import os
from time import sleep
import win10toast_persist as w10toast
toaster = w10toast.ToastNotifier()
my_env = os.environ
my_env['GOOGLE_API_KEY'] = 'no'
my_env['GOOGLE_DEFAULT_CLIENT_ID'] = 'no'
my_env['GOOGLE_DEFAULT_CLIENT_SECRET'] = 'no'
eel.browsers.set_path('chrome', 'chromium/chrome.exe')
# initializing the application
eel.init(f'{os.getcwd()}\\mhat')
@eel.expose
def notif(title, message):
toaster.show_toast(
title,
message,
duration = 3,
icon_path = "icon.ico",
)
def close_callback(*args, **kwargs):
pass
eel.start('index.html', size=(600, 430), block=True, on_close=close_callback)
Here is my index.html:
<script src="/eel.js"></script>
<script>
if (localStorage.getItem('username') === null || localStorage.getItem('password') === null) {
window.location.replace('/login.html')
}
else {
window.location.replace('/app.html')
}
</script>
And also, in the login.html, if WebSocket disconnects, it sets the app HTML to this:
<p>You have been disconnected. Press the button down below to try reconnecting.</p>
<br><button class='btn' onclick='window.location.reload()'>Reconnect</button>`
And also, "window.location.replace" function is used not only in the index.html file.
I've tried:
Building the app with this command:
pyinstaller -F main.py --icon icon.ico
Building the app with this command: ~pyinstaller -F main.py --icon icon.ico --hidden-import bottle_websocket --add-data C:\Users\Roman\AppData\Local\Programs\Python\Python38\lib\site-packages\eel\eel.js;eel`
Building the app with this command:
python -m eel main.py mhat -F --icon "icon.ico"
But unsuccessfull.