Python + Prism == Your own Rich Internet Architecture?
So what happened is, we needed to build this application at work and it fell upon me to do it. For various reasons, I decided to write the app in a web client/server style where I wrote the app in python/web.py and a regular browser was used to access it. In other words, your fairly standard web app.
Eventually, it was decided that this model wasn’t very convenient from an end-user point of view. The need to setup a separate web server (or integrate with an existing server) just to serve the app was a bit too much of a hassle. Plus, all of Firefox’s chrome made this app not feel like an app! So what’s a guy to do?
I decided to use webpy’s baked in server to host the app and Mozilla’s Prism as a client for the app. With the following bit of logic, both the client and server can be invoked from the same piece of code.
#!/usr/bin/env python # File: ria.py # Author: Deepak Sarda import subprocess import thread import web def launch_browser(*args): try: # Assuming you already have a Prism webapp profile mapped to http://localhost:8080/ retcode = subprocess.call(['prism', '-webapp', 'helloworld@antrix.net.prism.app']) except: print 'Failed to create client interface' print 'Client exited. We can exit too!' thread.interrupt_main() class App: def GET(self): print """<html><head><title>Hello World!</title></head> <body><h2>Hello World!</h2><p>If you can read this, then you have just created your very own RIA!</p></body></html>""" if __name__ == '__main__': thread.start_new_thread(launch_browser, ()) web.run(('/', 'App'), globals())
Create a shortcut to ria.py
and you have your own RIA solution! For bonus points, process all of the python code, web.py, database modules and what not with bb-freeze and you have a zero-install - just unzip and run - RIA!