Modufy the of your to:
import eel
eel.init('C:\Users\Fantomas\Documents\Programming\cipher\web')
@eel.expose
def startEncryption(mode : int, message : string, code : string):
if mode == 1:
ciphertext = encryptMessage(code, message)
elif mode == 2:
ciphertext = decryptMessage(code, message)
return ciphertext;
eel.start('main.html')
put eel.start('main.html')
after exposing all shared functions.
Looking for your comments.
Good Luck
Obviously, Not placing eel.start at the end of your code often causes the problem, But eel.init’s position has nothing to do with this particualar issue.
I just wanted to tell you that sometimes, The issue is not with your py code itself, But rather with the part where you import eel into your html code, Remember, the eel.js is always generated wherever your eel.init folder has been specified as, So when importing your eel.js in your html code, Make sure its in that particular folder
For example, If you have specified a folder web in your py code:
PYTHON:
eel.init('web')
Then When you import eel in html, It must be like the following
<script src="./eel.js"></script>
NOTE: Here, The .html file is also in the web folder, And so eel.js is imported from the same directory.
So yeah, This often happens(Atleast to me) Make sure you didnt make a mistake while importing eel.js in your html code.
This is my first time trying something out with eel. I’ve got a python script with some functions and I’m trying to communicate with them using @eel.expose
but it gives me a javascript error – main.html:10 Uncaught TypeError: eel.startEncryption is not a function
Here’s my code:
<head>
<title>Undefined</title>
<link rel="stylesheet" href="w3pro.css">
<script type="text/javascript" src="/eel.js"></script>
<script>
function startEncryption(mode){
massage = document.getElementById("massage").value;
code = document.getElementById("code").value;
string = eel.startEncryption(mode, massage, code);
document.getElementById("result").innerHTML += string;
}
</script>
</head>
<body>
<header class="w3-panel">
<h1>Vigenere Encryption</h1>
</header>
<div class="w3-panel">
<span>Message:<input type="text" id="massage"></span>
<br>
<span>Code:<input type="text" id="code"></span>
<br>
<span>Encrypted/Decrypted:<input type="text" id="result" readonly></span>
<br>
<input type="button" value="Encrypt" onclick="startEncryption(1)">
<input type="button" value="Decrypt" onclick="startEncryption(2)">
</div>
</body>
import eel
eel.init('C:\Users\Fantomas\Documents\Programming\cipher\web')
eel.start('main.html')
@eel.expose
def startEncryption(mode : int, message : string, code : string):
if mode == 1:
ciphertext = encryptMessage(code, message)
elif mode == 2:
ciphertext = decryptMessage(code, message)
return ciphertext;
I’ve got the eel.js file in my directory
put a short version of your python code which is valid run.
Put your python code including all the parts related to eel, starting from importing up to starting the HTML file. In addition, the body part of the HTML contains the
thanks it worked, I didn`t know i had to specify the exposed function before the start of the app