Thursday, 23 May 2013

Building web apps with Python

Well, as much as coding sucks, I love it -so much in fact, that I spend an inordinate amount of time doing crazy things using the incorrect tools for the job at hand - just for the kick of getting it to work!

Well, recently, I have been prone to the urge to use different languages to augment my website - for those of you who don't know, I am a software developer, who does web development in his spare time... Actually, my new job involves copious amounts of web development - but that is another story.

Well, my current occupation allows me to do web development, and throw in "hardcore" programming languages into the mix - just for fun.

So, one day I decided that our company intranet needed a way of sharing files - not a Samba share (Shared folder on Windows), not an FTP server - because FTP causes too much back and forth network traffic.... and certainly not using anything "standard" like PHP or JavaScript!

No, I opted to use Python... So, I set up Apache, and got cracking ... mind you, it was not as simple as I thought it would be, but as it turns out, Python is quite capable of this task- with relatively little code ... It's quite simple, you edit your httpd.conf file to include python files to run as cgi scripts, which can then run in any folder... then you get cracking writing your python script...

Of course, you would need a fixed IP for the server to be of any use, but it is rewarding enough to crank up your browser and see a web page that your Python code spat out...

 I have included a screenshot of the web app running - along with the tools which were created with it:

*note that the image was doctored slightly to remove company information ... but the layout and look and feel are 100% correct. The left side shows the home page which lists all the services this app provides, and the right page is the "download" service running in my chrome browser window.

Well, let me tell you that Python is quite a dream for writing web apps - especially to a C/C++ programmer who is used to banging out 1-3000 lines of code before morning coffee... This entire web app, with all associated services comes in at under 3000 lines of code - without refactoring to remove common code!

Anyone interested in building web apps with Python should be aware that there are numerous security risks which Python is addressing as I type this. In the near future we might see python becoming the dominant web 2.0 language of choice for building awesome web apps.

Have fun ... my next project is to write a Windows Gadget Game using JavaScript and some clever DOM tricks I picked up along the way...