Created
October 24, 2011 04:03
-
-
Save igorgue/1308355 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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