Flask with pywebview Example

Flask with pywebview Example

I mashed up 2 things:

Here’s the project dir structure (minimal Flask):

C:\Users\joeco\PycharmProjects\pyWebviewFlask>tree /F /A
Folder PATH listing for volume Windows
Volume serial number is F2FB-4810
|   pyWebviewFlask.py
|       encodings.xml
|       misc.xml
|       modules.xml
|       pyWebviewFlask.iml
|       workspace.xml

Here’s the code in pyWebviewFlask.py:


__author__      = "Joe Dorocak (JoeCodeswell@gmail.com)"
__copyright__   = "Copyright 2016, Joe Dorocak (JoeCodeswell.com)"
__license__ = "MIT"

PyCharm project type: flask
Templating language (std for Flask) : Jinja2
pywebview == webview: https://github.com/r0x0r/pywebview (by Roman Sirokov already installed for py2 & py3)

Flask views: http://flask.pocoo.org/docs/0.11/tutorial/views/


from flask import Flask

import webview
import sys
import threading

app = Flask(__name__)

def hello_world():
    return 'Hello to the World!'

def start_server():

if __name__ == '__main__':
    """  https://github.com/r0x0r/pywebview/blob/master/examples/http_server.py

    t = threading.Thread(target=start_server)
    t.daemon = True

    webview.create_window("It works, Joe!", "")


Here’s a link to a screenshot of the result:


2 thoughts on “Flask with pywebview Example

  1. Hello !
    I try to make a desktop app from a website, which i could just launch from my desktop by double clicking… i succesfully managed to make the ‘It Works’ window with an actual website in, but how can i save it ? like in a/several .py file ?
    Thanks by advance !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s