Advice on converting a python program to a web app?
September 19, 2012 5:04 AM Subscribe
Hi
I have programmed on eclipse, a reasonably straightforward program in Python 2.7 that applies image filters to user selected images e.g. by turning them to sepia, black & white, negative, etc. It uses Tkinter for the graphics user interface and the program functions ok. However, I was thinking about how to turn this into a web app. So to transfer this to an Amazon cloud server, I understand that for the client side user interface I would need to convert the program by adding html and javascript to the client side while python handles the server side? Does anyone know of any tutorials or other resources that are particularly good at covering web apps like this using python, html and javascript?
posted by conrad101 to computers & internet (3 answers total) 3 users marked this as a favorite
Presumably you have a class or function that takes an image file writes another.
Your best bet is to use a micro framework like flask or bottle to handle the upload, pass it off to your class and write it to a public static directory. These frameworks will give you what you need to handle requests, uploaded files, serve templates to the user, etc.
Follow the simple tutorials and use a the development server until you get something working, then deploy it on amazon. A basic set of steps might be:
Log onto your ec2 instance
Install python
Install nginx
Install something like gunicorn as a wsgi server.
Put your flask project on the server
Configure everything (there are tutorials depending on what technologies you decide to use, here's one http://wirtel.be/posts/en/2011/02/24/nginx_gunicorn_flask/)
You should probably use virtualenv, but it can be daunting and add some configuration steps, so maybe skip it for now if you're new to python deployment.
If your image processing takes a long time and you expect a good amount of traffic, you're going to want a way to do that processing outside of the web request. There are many ways to do this, Celery is one.
posted by miniape at 5:56 AM on September 19, 2012