Eric J Ma's Website

Desktop Python applications with Flask

written by Eric J. Ma on 2021-05-12 | tags: python software development til


Today, I learned that it's possible to create a desktop app that uses Flask as the webserver, Python for application logic, and HTML/CSS/JS for the front-end.

The logic basically that we split the desktop app code into the front-end and back-end, and we let the front-end and back-end communicate data using JSON. The backend code does whatever complex logic is needed, while the front-end code simply does the rendering. It's basically a very familiar pattern for server-based applications.

One tool that helps with this is flaskwebgui, by GitHub user @ClimenteA. I found out about this tool by reading a dev.to article on using FastAPI to create a desktop application.

I also saw another article on using Svelte.js + Flask to create a Python app. That one also looks like a simple pattern to follow, with the advantage that Svelte.js makes reactivity very simple.

Of course, if you're looking to stay in a single language without this separation of concerns, it's feasible to stay with a single framework, like Streamlit, ipywidgets, Panel, and more. Indeed, for some projects, it may be more pragmatic to stick with a single language depending on the language skillset of those working on that project.


I send out a newsletter with tips and tools for data scientists. Come check it out at Substack.

If you would like to sponsor the coffee that goes into making my posts, please consider GitHub Sponsors!

Finally, I do free 30-minute GenAI strategy calls for organizations who are seeking guidance on how to best leverage this technology. Consider booking a call on Calendly if you're interested!