I’m pretty new to Python because I haven’t used it much for many projects over the years, but i decided to use it to make a web app recently with flask to practice. It calls a simple python program that does some file conversion. There’s no database.
I’m hosting it on Python Anywhere for free right now. It’s for an old TTRPG, so useful for a niche community, but probably not big enough to be worth hosting fees. Just in case, I’d also like to be able to keep an installer on my github or a Dropbox. The hope is others can still grab it, spread it, and install it long after I’ve lost interest or gotten hit by a bus.
From my googling, I see 3 main options:
- Path 1: Keep the basic structure of a web app and use one of the frameworks that let me run it in a computer’s browser offline.
- The options here seem to be Flaskwebgui, Electron, or NW.js.
- This seems the simplest and most straightforward way.
- Web GUI is ubiquitous nowadays.
- Part of me also doesn’t like that everything has become a web app. I don’t even know why. Maybe I don’t like the idea of Google controlling everything.
- Path 2: Keep the basic backend logic but rewrite the web GUI with a desktop GUI, making it more of a true native desktop app.
- The options here seem to involve using pyinstaller and then some python GUI library/framework like Tkinter, PyQt, PySide, or Dearpygui.
- I feel this will be slightly more work but it’s a super simple UI so remaking it isn’t a huge deal.
- My instincts tell me the end result might be faster, since it won’t have to deal with a browser middleman or web routes and such. But, I might be wrong, it might just be my old-ass not used to everything being an electron app nowadays.
- Might also be more self-contained from carrying it’s own libraries and not relying on browser compatibility? Idk.
- Probably more OS dependent, though. Not sure how easy it is to make it work with PC, Mac, and Linux users.
- Path 3: There seems to be some way to combine flask and pyinstaller so sounds like a combination of the two is an option, too. Haven’t looked into this too much though since most of my search results talked about the above two paths.
So which way is best? And which framework/library/tool in that path?
My highest priorities are having it useful for a variety of users, lasting awhile, and general quality (responsiveness, actually works, etc). After that I’m pretty evenly split between doing it quickly, doing it in a way that would help me learn more Python for my career, and making it look good.
Depending on how complicated you’re willing to allow it to be to run locally, you could just run a webserver right on the desktop. Bind it to localhost:8000
so there’s no risk of someone exploiting it via the network, anf then your startup script is just:
- Start webserver
- Open browser to http://localhost:800/
It’s not smooth, or professional-looking, but it’s easy ;-)
If you want something a little more slick, I would probably lean more toward “Path 2” as you call it. The webserver isn’t really necessary after all, since you’re not even using a network.
One option that you might not have considered however could be to rewrite the whole thing in JavaScript and port it to a static web page. Hosting costs on something like that approaches £0, but you have to write JavaScript :-(
How big is the app? Distributing Python software is a colossal clusterfuck, so if it’s not enormous it may be easier just to translate it to another language that is easier to distribute, e.g. Typescript.
AI can make that relatively easy.
I’ll have to double check. More than 1000 lines but not sure by how much. But most of it is xml parsing so it’s possible that can be translated by an AI easily.
EDIT: But I was also hoping to use this as as an opportunity to learn more about Python so probably going with one of the other options, but I appreciate the ideas.
You don’t have to ask this question. You could have just read the source code yourself (i did). THEN offer advice.
Let me think about the worst possible advice, like it’s a competitive sport, can offer someone who is not confident in their python skills:
Hey! How about you port it to another language. Maybe C++ or assembly. Yeah yeah definitely assembly cuz has sex appeal and its what all the cool kids are doing.
I’ve been using path 3 and it was fine for me. I even adapted the docker-pyinstaller to also compile Mac-native binaries.
The thing is that in your case the users would still need to run front-end and back-end. Unless you want to implement some browser-starting logic (which is a pain to do multiplatform), this will be up to them ans that’s one click too many to start.
As far as I can tell you have such a problem with path 1 as well.
If it just does file conversion, could you make it a CLI program instead? Much easier task, rather than trying to figure out GUIs
I used InquirerPy in a project, very easy to use, and cross platform, works on windows as well, and still a bit more than a cli