Last active
January 20, 2018 09:42
-
-
Save CykuTW/b68dfd71fc08d56df008f76baf8b0fd3 to your computer and use it in GitHub Desktop.
It's just a teapot.
This file contains hidden or 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
| 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