0

My goal is to have a Python application that runs a web server which hosts the user interface, and based on interactions from a user in their browser, long running tasks get kicked off and through some process, feed status information back to the web server and subsequently back to the browser.

The application will not need to be used by more than 1 person at a time, and if 2 or more users are accessing the URL, the state should essentially be shared across all instances. That is, each user does not have unique login session.

The main purpose of the application will be to maintain a list of devices it discovers automatically on the network, and poll those devices every 30-60 seconds and update the UI if it is being used. In addition, the user can select one or more of those devices and issue commands or upgrade their software. In the instance of the software upgrade, I would like to have it responsive enough where I could show real time progress bars for each device showing what % of the firmware has been uploaded.

My initial thought is something like web.py or Cherrypy for the GUI, now I'm just stuck on the best method to kick off those processes from the web server and how to feed the info back. I was thinking of having some daemon listen for commands on a socket which the web app would send, and it would use sockets to pass state back and forth between the daemon and the web. Then I still need to get that information smoothly from web to client so I was thinking of websockets for that.

I'm just looking for recommendations on some good practices for having the web interface communicate back and forth between the actual workers and then how to get the data from worker to web server to client browser.

The driving forces behind using the browser based approach is that the system itself must run on low cost hardware running Linux on x86 (not arm) with small amounts of memory. It could be a GUI app which we VNC into a machine to use but the headless method seemed better to me. I'm not 100% tied to this idea if anyone can suggest better alternatives.

  • I might be a bit late to the party, but here's what I did. I built a python websocket server and plugged into it with a HTML, CSS and Javascript application wrapped in a node-webkit frame. – Prinsig Aug 14 '15 at 13:12
2

'GUI' or web fronted

You can choose between several very easy and fancy web frameworks to build the frontend (you already mentioned web.py and Cherrypy). Personally I prefer Flask, which is actively maintained, widely used, easy to learn, very lightweight and has great docs/community.

'Backend' or asynchronous tasks

Celery is a good library to have tasks running asynchronously in background (e.g. checking your devices or whatnot) and sending data back to your application via a DB like Redis.

In summary you can set up a very simple Flask app in minutes and have it 'call' Celery workers. The only non-pythonic thing you will need is Redis allowing Workers/Flask app to communicate, but this is described in the Celery docs.

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.