Search code examples
pythonbrowserdesktophttpserver

Python Desktop Application with the Browser as an interface?


I want to create an application that runs on the users computer, a stand-alone application, with installation and what-not, but I want the interface to be a browser, either internal and displayed as an OS window or external accessible using the browser (i.e. some http server).

The reason would be because I know a little about Python, but I think I can manage as long as I have some basic roots that I can use and manipulate, and those would be HTML, CSS, and Javascript.

I've yet to find a good GUI tool which I can use, and always abandon the idea after trying to mess around and eventually not getting anything.


Solution

  • Python offers two things that should be of your interest:

    • a web server in the standard library
    • a standartized interface for web applications, called WSGI

    So it is relatively easy to add a web interface to your application. For example in Mercurial (the versioning system), you have a command hg serve that launches a web server.

    To see python launching a web server, and a WSGI app, just do:

    python -m 'wsgiref.simple_server'
    

    You can look at the wsgiref source code or some WSGI tutorial to do a simple app.

    After that, you may want to use a web framework (for templating & co), but that is another question...