public
Created

  • Download Gist
blog.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
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")

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.