Skip to main content

Create desktop applications with Flask/Django!

Downloads

Install

pip install flaskwebgui

Or download source file flaskwebgui.py and place it where you need.

Usage with Flask

Add bellow js code to your base.html (or to your script.js file)

<script>

document.addEventListener('DOMContentLoaded', function() {

    var url = 'http://127.0.0.1:5001/GUI-is-still-open'; 
    fetch(url, { mode: 'no-cors'});
    setInterval(function(){ fetch(url, { mode: 'no-cors'});}, 5000)();

});

</script>

In your main python file add bellow 3 lines of code

from flask import Flask
from flaskwebgui import FlaskUI #get the FlaskUI class

app = Flask(__name__)

# Feed it the flask app instance 
ui = FlaskUI(app)

# do your logic as usual in Flask
@app.route("/")
def index():
  return "It works!"

# call the 'run' method
ui.run()

Usage with Django

Make a file 'gui.py'(file name not important) next to 'manage.py' file in the django project folder.

Add the js code like we did it up.

Inside 'gui.py' file add these 2 lines of code:

from flaskwebgui import FlaskUI #import FlaskUI class

#You can also call the run function on FlaskUI class instantiation

FlaskUI(server='django').run()

Next run from your terminal the bellow command:

python gui.py

Configurations

Default FlaskUI class parameters:

  • app, ==> flask class instance

  • width=800 ==> default width 800

  • height=600 ==> default height 600

  • fullscreen=False ==> start app in fullscreen

  • maximized=False ==> start app in maximized window

  • app_mode=True ==> by default it will start chrome in app(desktop) mode without address bar

  • browser_path="" ==> path to browser.exe (absolute path to chrome C:/browser_folder/chrome.exe)

  • server="flask" ==> the default backend framework is flask (django is suported also), you can add a function which starts the desired server for your choosed framework (bottle, web2py pyramid etc)

  • port=5000 ==> specify other if needed, make sure to add port+1 in the js script

  • socketio=SocketIO Instance ==> Flask SocketIO instance (if specified, uses socketio.run() instead of app.run() for Flask application)

Should work on windows/linux/mac with no isssues.

Develop your app as you would normally do, add flaskwebgui at the end or for tests. flaskwebgui doesn't interfere with your way of doing a flask application it just helps converting it into a desktop app more easily with pyinstaller or pyvan.

Distribution

You can distribute it as a standalone desktop app with pyinstaller or pyvan.

Credits

It's a combination of https://github.com/Widdershin/flask-desktop and https://github.com/ChrisKnott/Eel

flaskwebgui just uses threading to start a flask server and the browser in app mode (for chrome). It has some advantages over flask-desktop because it doesn't use PyQt5, so you won't have any issues regarding licensing and over Eel because you don't need to learn any logic other than Flask/Django.

Submit any questions/issues you have! Fell free to fork it and improve it!

Release files for flaskwebgui 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flaskwebgui 0.1.11
File Size Uploaded
flaskwebgui-0.1.11.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flaskwebgui 0.1.11
File Interpreter ABI Platform
flaskwebgui-0.1.11-py3-none-any.whl Python 3 none any Details

Total release size: 12.6 kB

Release files / flaskwebgui-0.1.11.tar.gz

Download URL flaskwebgui-0.1.11.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9dd8f4bb78ab6cb1c7e35617a308e97a0b59827be039b3488a617a0069eaaa3c
BLAKE2b-256 checksum
How to use checksums
8fa1dec34f4b87d57716ffc23924bed3d4f05fdd9b383af9ddd7f0f7f367b948
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.2

Release files / flaskwebgui-0.1.11-py3-none-any.whl

Download URL flaskwebgui-0.1.11-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb48deadc6a629315f833a377cf68d82bfa55915068b4e8e0fd550a2682d8ada
BLAKE2b-256 checksum
How to use checksums
7d3610d0ef46cdb02b9bb7dfa71ba5d9da374a9199bf78a1945781fc9c9b8941
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.2

Release history Release notifications | RSS feed

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

This release

0.1.11 This release

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.6

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page