Skip to content

Instantly share code, notes, and snippets.

@amol-
Last active April 17, 2016 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amol-/204cb8eec2d7389eecc112bf93d62d12 to your computer and use it in GitHub Desktop.
Save amol-/204cb8eec2d7389eecc112bf93d62d12 to your computer and use it in GitHub Desktop.
Oneline TurboGears2 web application
from tg import expose, TGController, AppConfig
from wsgiref.simple_server import make_server
make_server('', 8080, AppConfig(
minimal=True,
root_controller=type('RootController', (TGController,), {
'index': expose()(lambda *args, **params: 'Hello World')
})()
).make_wsgi_app()).serve_forever()
@amol-
Copy link
Author

amol- commented Apr 17, 2016

Just run this with python tgoneline.py

I reindented it for readability but this can be collapsed as a oneliner:

make_server('', 8080, AppConfig(minimal=True, root_controller=type('RootController', (TGController,), {'index': expose()(lambda *args, **params: 'Hello World')})()).make_wsgi_app()).serve_forever()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment