Getting Started

TurboGears is a Python web framework based on the ObjectDispatch paradigm, it is meant to make possible to write both small and concise applications in Minimal mode or complex application in Full Stack mode.

Installing TurboGears

TurboGears is meant to run inside python virtualenv and provides its own private index to avoid messing with your system packages and to provide a reliable set of packages that will correctly work together.

$ virtualenv tg2env
$ tg2env/bin/pip install tg.devtools
$ source tg2env/bin/activate
(tg2env)$ #now you are ready to work with TurboGears

Single File Application

TurboGears minimal mode makes possible to quickly create single file applications, this makes easy to create simple examples and web services with a minimal set of dependencies.

from wsgiref.simple_server import make_server
from tg import expose, TGController, AppConfig

class RootController(TGController):
     def index(self):
         return "<h1>Hello World</h1>"

config = AppConfig(minimal=True, root_controller=RootController())

print "Serving on port 8080..."
httpd = make_server('', 8080, config.make_wsgi_app())

Play with it on Runnable or follow the Minimal Mode Tutorial to setup your own Single File Applications.

Full Stack Projects

For more complex projects TurboGears provides the so called full stack setup, to manage full stack projects the GearBox command is provided.

To try a full stack TurboGears application feel free to quickstart one and start playing around:

(tg2env)$ gearbox quickstart -n -x example
(tg2env)$ cd example/
(tg2env)$ python develop
(tg2env)$ gearbox serve

Visiting http://localhost:8080/index you will see a ready made sample application with a brief introduction to the framework itself.

Explore the Getting Started section to get started with TurboGears!