So you want to build a web application

So you want to build a web application

Everything is cloud based these days.. it's easy because you can access your work from every computer you have access to, you don't need a specific operating system or expensive system and if you're lucky your data is always synchronized as well.. ah yes, and it is annoying because it is always offline when you need it, it super slow and you just lost your privacy. That's about the summary I would give if people ask about my cloud experiences. But what is it like to write software for the cloud? To be more precise.. what is it like to write software for the cloud as an engineer? Let me tell you about about my experience and the options I have tried.

Framework oh framework.. where art thou?

No alt text provided for this image

In webland there are so many frameworks to choose from.. Svelte, React, Angular, Flutter, Django, ... the list goes on. With my background of C / C++ / Object Pascal and Python I really wanted to use something Python based because much of my app logic is already present in Python code. So I tried Django.. didn't like it.. Django also involves html, css, javascript or a framework like React and I just could not get used to the (for me) complicated interaction. So I tried Flutter.. great platform, definitely my number one choice for any project that does not require my Python code. I spend a lot of time learning Flutter and writing some apps but I still was not able to use my old code that already had so much logic I needed for the app I wanted to build.

Next idea.. split up the app in a frontend (the web app) and backend (API).

No alt text provided for this image

So there I was with one screen writing FastAPI code (excellent framework!) and one screen with Flutter for the web app. This was perfect.. but it became tedious to sync between both systems.. especially when the authorization came in.. even with Firebase (user friendly database / auth system (and more!)) it meant that I had to do everything from writing the API code, writing Flutter code to setting up the Firebase authorization and do loads of testing.

Then I got back to Python solutions..

No alt text provided for this image

There are some Python only frameworks. What about Viktor? A platform specifically made with engineers in mind. I liked it but I also disliked it.. It felt a little rough and the thing that was a no go for me was the way you are (were?) forced to use a strict layout system which did not allow me the freedom that I wanted. Maybe Streamlit then? Great for one page stateless apps but definitely not for multipage and more complex apps. So I almost gave up the idea of using Python for everything..

But then I found Anvil.

No alt text provided for this image

Never ever heard of it.. found it completely by accident but wow.. this did help! This platform allows you to write your own code and use their premade components to build a complete web application. You can design the user interface online, switch to the backend code and interact with the elements almost like I was used to write code in Delphi. It was really easy to code and I was up and running in no time.

Then I thought I ran into some complex problem.. the frontend could not import packages like matplotlib or numpy.. what now? But Anvil also has server functions and they do support other packages.. problem solved! Then again I thought I ran into a complex problem.. I could not install my own packages. But Anvil also allows you to bridge code with your local computer or even a Colab notebook.. or in my case a server running on Digital Ocean. Just a month ago they also released a beta version of the Python3.10 platform that allows you to add a requirements.txt to install all your packages, even those that are your own and/or private.

Next I found that the app was really slow so I probably needed the more expensive package they offer (isn't that always the case.. almost always..) but the amazing community and the devs of Anvil told me that I had to realize that every server call would spin a new Python virtual machine and reload all the packages so if I used complex packages that would cause a noticeable delay. So I moved all that code to the Digital Ocean droplet and response times dropped to super responsive levels (and I know how annoying web apps can be when they are not responsive!). Now a couple of months later I know this is the way to go. I have never been this productive. I can only write code for my app in weekends or in the evening so I don't need any distraction from setting up Docker images / deploying API's etc. etc. Every minute I spent on the app helps me forward. So yes.. I am really happy with Anvil and I think this might be true for other Python developers that face the same problems as I do (lack of time, large codebase in Python or dependencies on Python libraries for GIS / plotting / engineering).

My current setup is as follows.. all the logic is in a Poetry based Python library which is coupled to a CI/CD system in Gitlab. Every update of the code is checked and pull requests to the master branch will build a new version of the library and put that in the package registry. I rented a Digital Ocean droplet that serves the code that cannot run on the Anvil client side so there is no need for Anvil to spin up a Python VM for every server call. I got the affordable personal plan at Anvil, bought a 32'' monitor and this is where I write my code. As soon as it is production ready I think I will upgrade to the professional plan since I need more stages (dev / test / production) but we will see.. maybe when I am 80 it is still a hobby project ;-)

No alt text provided for this image

So here I am.. after trying out a lot of stuff I am back to Python only and it works like a dream. I can write my web application without the headaches of learning another language or writing API's and securing them.

Note that I am in no way related to the Anvil company.. I am just really happy they build this platform and I think they should get more attention because they are underrated. Great platform, very affordable and a great community with active developers.

Anyway, these are my two cents in the world of web app development and stay tuned because my leveelogic watersafety app will come online soon!

Short comparison

FastAPI

Very fast, asynchronous, easy to learn, easy to deploy, hard to secure, getting complex with celery and redis. Perfect if you want to just create an API

Flutter

Amazing portability.. MacOS / Windows / Linux / Web / Mobile, fast development, easy language (Dart), loads of components to use, state management can be confusing (provider / bloc etc), limited amount of libraries for engineers (as of yet!)

Anvil

Python only for backend, frontend, easy to deploy, very powerful with almost complete control over layout, paid (but reasonable), online IDE (but you can use a local IDE and git), time to production very short for Python devs

Viktor

Great integration with engineering software, great community. Limited control over layout, confusing state management, quite a steep learning curve compared to the other solutions.

Streamlit

Best platform for one page apps that do not have complex state management requirements, looks great, very short time to production, limited for complex apps.

Note that these are all my personal opinions, I am not paid for this article and your background is very important in your choice of platform. Unfortunately there is never one size fits it all.. but that's also part of the fun of development. Cheers!

Links to stuff I tried and liked:




Ad Leijtens

Sr. Business analist / Data analist / BI Consultant / Information analist / Python developer / Product Owner / Prompt Engineer and more

2 年

I had a kind of simular experience/quest and I fully agree with your conclusion: "I am just really happy they build this platform and I think they should get more attention because they are underrated. Great platform, very affordable and a great community with active developers."

Did you consider Dash (from the Plotly people)? I find it almost as easy to use as Streamlit, but much more powerful for building browser based dashboards.

要查看或添加评论,请登录

Rob van Putten的更多文章

社区洞察

其他会员也浏览了