I ran into a problem, if you look at the page that runs when you run the python file, then this error pops up. Sorry, the requested URL 'http://localhost:8000/index.html' caused an error:
File does not exist.
ok, if run via cmd, then: Traceback (most recent call last): File "C:\Users\Acer\Desktop\LP\py\Baym\logic.py", line 10, in eel.start("index.html") File "C:\Users\Acer\AppData\Local\Programs\Python\Python311\Lib\site-packages\eel_init_.py", line 200, in start run_lambda() File "C:\Users\Acer\AppData\Local\Programs\Python\Python311\Lib\site-packages\eel_init_.py", line 191, in run_lambda btl.run( File "C:\Users\Acer\AppData\Local\Programs\Python\Python311\Lib\site-packages\bottle.py", line 3175, in run server.run(app) File "C:\Users\Acer\AppData\Local\Programs\Python\Python311\Lib\site-packages\bottle_websocket\server.py", line 17, in run server.serve_forever() File "C:\Users\Acer\AppData\Local\Programs\Python\Python311\Lib\site-packages\gevent\baseserver.py", line 398, in serve_forever self.start() File "C:\Users\Acer\AppData\Local\Programs\Python\Python311\Lib\site-packages\gevent\baseserver.py", line 336, in start self.init_socket() File "C:\Users\Acer\AppData\Local\Programs\Python\Python311\Lib\site-packages\gevent\pywsgi.py", line 1545, in init_socket StreamServer.init_socket(self) File "C:\Users\Acer\AppData\Local\Programs\Python\Python311\Lib\site-packages\gevent\server.py", line 180, in init_socket self.socket = self.get_listener(self.address, self.backlog, self.family) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Acer\AppData\Local\Programs\Python\Python311\Lib\site-packages\gevent\server.py", line 192, in get_listener return _tcp_listener(address, backlog=backlog, reuse_addr=cls.reuse_addr, family=family) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Acer\AppData\Local\Programs\Python\Python311\Lib\site-packages\gevent\server.py", line 288, in _tcp_listener sock.bind(address) File "C:\Users\Acer\AppData\Local\Programs\Python\Python311\Lib\site-packages\gevent_socketcommon.py", line 563, in bind return self._sock.bind(address) ^^^^^^^^^^^^^^^^^^^^^^^^ OSError: [WinError 10048]
my code:
logic.py:
#pip install eel
import eel
eel.init("web")
@eel.expose
def ret(x):
print(x)
eel.start("index.html")
i
ndex.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="/eel.js"></script>
<script type="text/javascript" src="main.js"></script>
<title>s</title>
</head>
<body>
<input type="text" id="text">
<button onclick="data"></button>
</body>
</html>
main.js:
function data(){
var x = document.getElementById("text").value
eel.ret(x)()
}
ok, I searched through the jeepity chat, it didn't help, I searched on the forums, it didn't help. Eventually came here and I found a solution. Which didn't work for me( (There, it seems, people said to find the name of the file through the OS module, enter it into a variable, and already enter it into eel.start(), as I said, it did not help)
You need to store your static files in the web directory
https://github.com/python-eel/Eel#starting-the-app
Suppose you put all the frontend files in a directory called web, including your start page main.html, then the app is started like this;
eel.init('web')
app
├─logic.py
└─web(path name -> eel.init('web'))
├─index.html
├─main.js
├─css
└─img
eel.init()
-> def init(path: str, allowed_extensions: List[str] = ['.js', '.html', '.txt', '.htm',
'.xhtml', '.vue'], js_result_timeout: int = 10000) -> None:
path : points to your static file directory name
import eel
eel.init("web")
@eel.expose
def ret(x):
print(x)
eel.start("index.html")
When you modify the name of the web directory, you need to synchronously fix the path of init to the name you modified