I have a bunch of useful codes written in Python that would be useful for academicians / researchers / students / simple end users who don’t need to know the code. However, to use these codes I thought asking everyone to install Python and requisite libraries would be bothersome and somewhat wasteful (imagine a user who wants to visualize a shortest path algorithm is asked to install all these). A simple and well known solution is to convert these Python codes into web-based applications, so that the codes live on my server and computations happen on the server. The users provide the inputs over a web interface and get the outputs on the same interface.
Even though the task seems simple, I struggled initially to get it done. In spite of having big frameworks, e.g., Django / Flask etc., I found the simple CGI scripting much easier to understand and useful for this kind of applications, even though it requires a bit of coding. A Python CGI script is a Python script that generates a webpage dynamically and uses the standard tags of the HTML for I/O. An introductory tutorial is here. The advantage is that you can convert your Python code into an web-application quite quickly. Of course, you need to worry about giving the CGI scripts executable permission and have to set your (Apache) server to render those scripts to be executable on the web. But there are tutorials available on how to do that. What I finally struggled with is to get a web-hosting site where I can put my scripts to run. Turns out that there were many such sites (an example list is here), and I simply missed them for not searching with appropriate keywords.
Now, things are all set. You have written a basic Python code – converted it into a Python CGI script – found a host that lets you execute the CGI scripts – populated the appropriate directory with the scripts and voilà, your scripts are online. I’m sharing my experience as many would like to do the same.
As an example of how I did it, I have written a Python script that runs the Gale-Shapley deferred acceptance algorithm (you can google it for more details) to match students to advisors. It can as well be used for matching students to schools / departments having a fixed capacity. A sample output is here. The whole project is on GitHub. The Facebook page for this app. “Like” it if you like it. There are still some updates required for this app since I haven’t included error handling much. But basically it does what I wanted.