Speed up development with full-stack environments for every branch.

Learn More

Rapid Prototyping REST API with TurboGears [Python]

Forked from Basic TurboGears Example.

66 Runs 272 Views 46 Copies
Saved

Saved

amol 16

amol
published 3 years ago

from wsgiref.simple_server import make_server
from tg import AppConfig

import angulartg


config = AppConfig(minimal=True, root_controller=angulartg.RootController())
config.renderers = ['json', 'genshi']  # INDEX page will use Genshi, while REST API will use JSON
config.package = angulartg  # Make TG look for models inside angulartg package.
config.use_sqlalchemy = True 
config.paths.templates = './angulartg'  # We have templates directly inside the package, not in a subpackage.
config.use_toscawidgets2 = True  # This is required by tgext.crud to autogenerate REST API.

DEPLOY_OPTIONS = {
  'sqlalchemy.url': 'sqlite:///'  # Use an in-memory SQLite database.
}
httpd = make_server('', 80, config.make_wsgi_app(**DEPLOY_OPTIONS))

print "Serving on port 80..."
httpd.serve_forever()
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).