Python the language

For the longest time I avoided it. Mainly because I didn’t have a use case for it. I use C for mostly everything and recently when I was attempting to do some web programming it was PHP and JavaScript. Both PHP and JavaScript are just painful to use. PHP because of some of the ways you have to write out variables and if those variables are to return values. I struggled a lot. JavaScript was mainly for whatever to be used at the front end (user-visible). The problem becomes that you generally have to use both languages to get something done.

So I had a simple task tracker I wanted to write using web technologies. I wanted to use the web stuff because I have a QNAP device with a web server on it. However, the web server on the QNAP is restricted to PHP at best on the server-side scripting. I might be able to get Python on there but it is not a trivial thing to enable as you pretty much have to get into the machine with some SSL connection and configure it. To me, that’s pretty much out of the question. I do not like to toy with my backup device like that. So PHP, Javascript solution was attempted.

First try, getting PHP to read in simple text files and display to the user. A mixed bag of PHP and Javascript and it became an unholy mess. When you are delegating certain things to be done on the server side and other things to be done on the client side, I find you lose track who is responsible for what.

Second try, light server side, heavy client side. So attempting to do as little as possible on the server side just to reduce the amount of frustration I was having with PHP at the time. This was ok but dynamic web pages on the client side with JavaScript is another pain. It was working reasonably well but it was still rather painful as there is still a large two systems one application vibe.

Third try, server only coding and the client side is pretty dumb. This means a lot of PHP coding. Played around with the data storage in that the data store was writing to PHP script so that the PHP interpreter was the importer of data instead of having to wring my own file parser/importer in PHP. Learned a lot of PHP here but still frustrating to program. I did get it to a state where I was actually using the results. But augmenting the code for new features was painful.

So I decided to give up on having the app work on the QNAP. I was developing using XAMPP on my machine anyway so the new method is to write the app with the understanding that it will be run on the local machine using XAMPP. The web server will be serving from a Google drive folder so that it will be synched with the other machines. I suppose I could point the web server to use a folder on the QNAP but doing this for the time being. The language now is not restricted to PHP or Perl. So I tried python. Setting up XAMPP for python is pretty simple. Python is a MUCH more sane language to work with than PHP, Perl, or JavaScript. Nothing truly bizarre and what I know in C/C++ is pretty much what Python works with. There are some gotcha’s but nothing horrendous.

Granted I tried to write the same application something like 3 times already but the ‘joy’ of programming in Python for this web app is a night and day difference compared to the pain in PHP. Again, I am following the third attempt and doing practically everything on the server side. This means I do not have to complicate things on two sides. For my needs, the inefficiency of sending the data again and again to the web browser is negligible. It’s not pretty but it is working. And working rather well. Easy to add things too.

Source code on Github. https://github.com/Zekaric/ZMYT

At the time of writing, I have to update the documentation. It is still the documentation of the PHP version so it is mostly wrong. In short, just put the files into their own folder and point the browser to that folder. Add a project first and then you can add tasks.

HUGE WARNING: The code is not intended to be internet facing or to be used in a multi-user environment. It is just a simple task tracker for one person. Namely me. But someone else might find use from it.

Leave a Comment

Your email address will not be published. Required fields are marked *