Python Eel: "Access Denied"

Question:

I’m trying to use Eel to make a simple application, but when I run this simple code:

import eel
from os import getcwd
eel.init("web")
eel.start(getcwd() + "\main.html")

It gives me this error:

Error: 403 Forbidden

If it’s important, here is the html code, just a placeholder to test:

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <body>
    <h1>Test</h1>
  </body>
</html>

I’ve tried changing ownership of the file to ‘Everyone’ and giving full access, but that didn’t do anything. I couldn’t find anything about this online when I searched for it, so if anyone knows how to fix this, please let me know. TIA!

Asked By: Fun840

||

Answers:

This app.py worked for me:

import eel

if __name__ == '__main__':
    eel.init(".")
    eel.start("main.html")

With my directory structure:

/project
  |app.py
  |main.html

With the code you posted, you would need a directory structure like:

/project
  |app.py
  /web
    |main.html
Answered By: mole1000

I just restarted my vs code, and it’s worked for me.

Answered By: Mateo
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.