1

If I built some useful piece of python code to e.g. scrape a website or to calculate something big, at some point I might want to add a GUI to my project. For this I could use Tk, Qt, Pygame or any python graphic/GUI framework.

Now I also want this tool to be usable by clients without the need for a python installation. Of course I could use something like py2Exe or py2Dmg. But wouldn't it be cooler to use a python-based web framework for this? Something like Django or Pyramid.

What would be the drawbacks of doing this? Can I just use the framework to execute my code on a server and only return the result? Or will this get tricky when there are multiple users?

1

Making a web UI will make it easier to extend, and update. But it will be another layer of complexity for you to deal with.

I recommend looking at the lightweight http://webpy.org/

    urls = (
        '/hello', 'hello'
    )
    app = web.application(urls, globals())

    class hello:        
        def POST(self, name):
            #call your script here

You can call this with POST localhost/hello

Benefits:

  • Portability: no installers, can access from anywhere.

  • Extensibility: easyer to modify the UI (if you know HTML/CSS) and easier to re-deploy your application.

drawbacks:

  • Complexity: you will need to understand HTML, CSS request/response etc, set up a webserver or shared hosting,

  • Security: don't make it public.

| improve this answer | |
  • Thanks! I already have experience with Django so the complexity won't be to much of a problem. What's with security? Why would this construction be extra vulnerable? – SwenMulderij Dec 6 '13 at 15:46
  • if you make your web server accessible to the internet, people may try and attack it. There are all kinds of attacks to watch out for, it's probably best/easiest to set up a firewall to allow internal network access only owasp.org/index.php/Top_10_2013-Top_10 – roo2 Dec 6 '13 at 15:53
0

If you use Django, I recommend looking at either of

  • django-tastypie. With it you can build simple REST-style interfaces to your code.
  • Celery. An asynchronous task framework

Since you mention calculating something bigyou are likely to need asynchronous processing. Celery is a great choice for that. It includes the ability to submit jobs via REST calls, and to check on their status.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.