Hi, I'm ThadeusB.

I code stuff. I raise bees. I game.

Compile web2py apps externally

Web2py has a nice built-in feature supported execution of byte-code compiled applications. When you compile your application, web2py actually will byte-code compile all models, controllers and views. Web2py is the only framework to date that will compile your views as well!

The end result is a much faster application. Since this is the most desired way to run web2py on a production system, we need a way to compile the application externally. Either through a build tool or if you do not have access to the "admin" application on your production server.

It is very simple, use this quick one-liner from the root web2py directory.

python -c "import gluon.compileapp; gluon.compileapp.compile_application('applications/<appname>')"

Compiling your application has another added benefit. You can update your application code, and web2py will continue to use the already compiled version. This way you do not have to bring your site down for a simple upgrade! Just be sure to re-compile when your ready to use the new code.