Skip to content

Instantly share code, notes, and snippets.

@zupo
Created December 8, 2016 13:27
Show Gist options
  • Save zupo/8a1f662eb10a89ed52a6e779cf876239 to your computer and use it in GitHub Desktop.
Save zupo/8a1f662eb10a89ed52a6e779cf876239 to your computer and use it in GitHub Desktop.
"""Showcasing Pyramid's Function Decorators.
Usage:
1. Install Pyramid: http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/install.html
2. Put this code into example.py
3. Run with ``$VENV/bin/python example.py``.
You can showcase with your browser or using curl:
$ curl http://localhost:8080/
Welcome!
"""
from pyramid.config import Configurator
from pyramid.response import Response
from pyramid.scripts.pserve import wsgiref_server_runner
from pyramid.view import view_config
@view_config(
route_name='home'
)
def home(request):
return Response('Welcome!')
if __name__ == '__main__':
config = Configurator()
config.add_route('home', '/')
config.scan()
wsgiref_server_runner(config.make_wsgi_app(), None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment