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.
@article{
ericmjl-2021-desktop-flask,
author = {Eric J. Ma},
title = {Desktop Python applications with Flask},
year = {2021},
month = {05},
day = {12},
howpublished = {\url{https://ericmjl.github.io}},
journal = {Eric J. Ma's Blog},
url = {https://ericmjl.github.io/blog/2021/5/12/desktop-python-applications-with-flask},
}
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 teams that are looking to leverage GenAI for maximum impact. Consider booking a call on Calendly if you're interested!