Skip to content

Instantly share code, notes, and snippets.

@CykuTW
Last active January 20, 2018 09:42
Show Gist options
  • Save CykuTW/b68dfd71fc08d56df008f76baf8b0fd3 to your computer and use it in GitHub Desktop.
Save CykuTW/b68dfd71fc08d56df008f76baf8b0fd3 to your computer and use it in GitHub Desktop.
It's just a teapot.
from flask import Flask, abort
from flask.views import MethodView
app = Flask(__name__)
class Teapot(MethodView):
methods = ['BREW']
def brew(self):
abort(418)
app.add_url_rule('/', view_func=Teapot.as_view(Teapot.__name__))
if __name__ == '__main__':
"""
example:
> curl -X BREW 'http://127.0.0.1:5000/'
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>418 I'm a teapot</title>
<h1>I'm a teapot</h1>
<p>This server is a teapot, not a coffee machine</p>
"""
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment