I am creating a GUI application using eel library in python. index.html
contains login form and if login is successful I want to open retrieve.html
.
This is my python code and please consider login as successful.
@eel.expose
def retrieve():
eel.start('retrieve.html', size=(1000, 700))
eel.start('index.html', size=(1000, 700))
This is my javascript code
function login_func()
{
var username = document.getElementById("username").value
var pword = document.getElementById("pword").value
eel.login(username, pword)(set_result)
}
function set_result(result)
{
if(result == "Failed")
{
window.alert("Please insert correct username and password")
}
else
{
window.close()
eel.retrieve()
}
}
Everything works fine but I am getting an error message and that is
OSError: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted: ('localhost', 8000)
How can I avoid this?
Use different port No. for 2nd window, as mentioned below:
@eel.expose def retrieve(): eel.start('retrieve.html', size=(1000, 700), **port = 8080**)
eel.start('index.html', size=(1000, 700), port = 8000 )
or Alternatively, check this https://deecode.net/?p=438&lang=en
Make sure that the your port is different for each window
You shouldn't call eel.start
again... that will setup a new local server, websockets, etc. In this case, you can call eel.show
which will re-use your existing web instance to show the new window and page.
So change your code to something like:
@eel.expose
def retrieve():
eel.show('retrieve.html', size=(1000, 700))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.