Package: django-eel
Django-EelDjango-Eel is a Django App for HTML GUI applications, with easy Python/JS interoperation. It is a porting version ofEel.Repo branchesmaster: the master branch of Django-Eeleel-master: keeping sync withEel/masterRequirementsDjango ( >=2.0.7 recommended )channels ( >=2.1.2 recommended )gevent ( >=1.3.4 recommended )Getting StartedInstallationDownload Django-Eel package from GitHub and install:python setup.py installOr install through PIP:pip install git+https://github.com/seLain/django-eelCreate demo projectCreate an empty django project:django-admin startproject demoCreate examples django app:django-admin startapp exampleAddchannels,django_eel, andexampletodemo/settings.pyINSTALLED_APPS=['django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','channels','django_eel','example',]Set ASGI_Application indemo/settings.py. It is required by channels.WSGI_APPLICATION='demo.wsgi.application'ASGI_APPLICATION="demo.routing.application"Addroutine.pyunderdemoproject root. Theroutine.pyroutes websocket requests toEelConsumer.fromchannels.routingimportProtocolTypeRouter,URLRouterfromdjango.conf.urlsimporturlfromdjango_eel.consumersimportEelConsumerapplication=ProtocolTypeRouter({# (http->django views is added by default)"websocket":URLRouter([url(r"^eel$",EelConsumer),# do not alter this line]),})Configure demo\urls.py to route http request to eel and example respectively.urlpatterns=[path('admin/',admin.site.urls),url(r'^eel/',include('django_eel.urls')),# do not alter this lineurl(r'^example/',include('example.urls')),# set by your app name]That's the configuration part. Now we add a helloword example.Create template and viewCreateexample\templates\example\hello.html:<!DOCTYPE html><html><head><title>Hello, World!</title><!-- request for eel.js from django-eel, do not alter this line --><scripttype="text/javascript"src="/eel/eel.js"></script><scripttype="text/javascript">eel.expose(say_hello_js);// Expose this function to Pythonfunctionsay_hello_js(x){console.log("Hello from "+x);}say_hello_js("Javascript World!");eel.say_hello_py("Javascript World!");// Call a Python function</script></head><body>Hello, World!</body></html>Thishello.htmlis almost the same as the originalEelexample, except the request foreel.js.Then we create the viewfromdjango.shortcutsimportrenderimportdjango_eelaseel# initialize eeleel.init('example/templates/example')############################ Hello example###########################defhello_page(request):# accept request for hello.htmlreturnrender(request,'example/hello.html')@eel.exposedefsay_hello_py(x):print('Hello from%s'%x)eel.say_hello_js('Python3 and Django World!')# call js function############################ Open local browser###########################eel.start('example/hello',size=(300,200))# optional for off-line browsingFinally, we have to setexample\urls.pyto handle the request to example pages.fromdjango.conf.urlsimporturlfrom.viewsimporthello_pageurlpatterns=[url(r'^hello$',hello_page),]Running the demoSimply run the django project as usual:python manage.py runserverA browser windows should popup if this line is added in view.eel.start('example/hello',size=(300,200))You can also access the hello example by browser:http://localhost:8000/example/helloThat's it. All behaviors are basically the same as the originalEel.