python-eel / Eel

A little Python library for making simple Electron-like HTML/JS GUI apps
MIT License
6.38k stars 583 forks source link

Do I really need to use "eel.start" to use my Python Functions in my JS file(s)? #568

Closed Attachment-Studios closed 2 years ago

Attachment-Studios commented 2 years ago

Some simple query... All I'm really asking is that if its possible to use

@eel.expose
def myPyFunc():
    # do whatever
    return "My Return Value"

And what to do for doing this.

Thanks...

Also if you are imagining file system:

-root
|-\web
|  |-index.html
|-main.py

And All code so far main.py

import eel
import flask

app = flask.Flask(__name__)

@app.route('/')
def home():
    with open("web/index.html", "r") as html:
        return html.read()

eel.init('web')

@eel.expose
def encode(data:str):
    # encoding comes here
    return f"This Value For Now... Soon Will Be Replaced By Encoding Of {data}"

if __name__ == "__main__":
    app.run(host='0.0.0.0', port='2022')

index.html is empty...

Thanks(Again, In Future)

Attachment-Studios commented 2 years ago

I'm closing this issue, I managed to do alternatives and it worked... But a combo with flask would had been really great... I hope this might become a feature in future...