Skip to main content

Minimal Web Browser

Project description

open-marquesote

Minimal PyQtWebEngine web browser useful to serve python web apps in desktop.

Preview

Live sample can be found at Cacao Accounting Desktop, just replace the app to be served with your own project, please note that we recomend the Waitress WSGI server since it is croos plataform, Gunicorn olny runs in Unix.

Example

# example.py
import subprocess
import time
from sys import argv, executable
from flask import Flask
from PyQt5.QtWidgets import QApplication
from open_marquesote import MainWindow
from waitress import serve

flaskapp = Flask(__name__)


@flaskapp.route("/")
def app():
    return "A python web app running like desktop app."


def server():
    try:
        serve(flaskapp, threads=2, port=9889)
    except OSError:
        # If the server was started before and is still running there will be a OSError: [Errno 98] Address already in use
        # Since the server is already up and running we pass this error.
        pass


def browser():
    time.sleep(5)  # Give 5 seconds to the WSGI server to start.
    browser = QApplication(argv)
    window = MainWindow(url="http://127.0.0.1:9889/", appname="Python web in Desktop")
    browser.exec_()


def run():
    subprocess.Popen(
        [executable, "-c", "import example; example.server()"],
        stderr=subprocess.DEVNULL,
        stdout=subprocess.DEVNULL,
    )
    subprocess.Popen([executable, "-c", "import example; example.browser()"])


if __name__ == "__main__":
    run()
pip install -r requirements.txt
pip install flask
python example.py

Preview

License

Copyright 2017 Martin Fitzpatrick Copyright 2020 William Moreno Reyes

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

open-marquesote-1.0.1.tar.gz (100.8 kB view hashes)

Uploaded Source

Built Distribution

open_marquesote-1.0.1-py3-none-any.whl (106.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page