Skip to content

Instantly share code, notes, and snippets.

@igorgue
Created October 24, 2011 04:03
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 igorgue/1308355 to your computer and use it in GitHub Desktop.
Save igorgue/1308355 to your computer and use it in GitHub Desktop.
import json
def allowed_methods(request):
return ['HEAD', 'GET', 'PUT', 'DELETE', 'POST']
def content_types_provided(request):
return {'text/html': to_html, 'text/plain': to_text, 'application/json': to_json}
def is_authorized(request):
return True
def to_html(request):
return "<h1>Hello, World!</h1>"
def to_text(request):
return "Hello, World!"
def to_json(request):
return json.dumps({'message': "Hello, World!"})
# XXX
from werkzeug.wrappers import Request, Response
@Request.application
def hello_world(request):
# 1. The allowed methods
if not request.method in allowed_methods():
raise Exception("Fuck")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment